From: Leonardo Florez-Valencia Date: Tue, 23 Dec 2014 11:10:09 +0000 (+0100) Subject: Garbage collector added X-Git-Tag: v0.1~433 X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=cb833d2fface96e020fe91584d2206860a8174ee;p=cpPlugins.git Garbage collector added --- diff --git a/appli/ImageMPR/ImageMPR.cxx b/appli/ImageMPR/ImageMPR.cxx index 26c8f34..1d05703 100644 --- a/appli/ImageMPR/ImageMPR.cxx +++ b/appli/ImageMPR/ImageMPR.cxx @@ -46,7 +46,6 @@ ImageMPR:: // Delete objects delete this->m_UI; delete this->m_MPR; - if( this->m_InputImage != NULL ) delete this->m_InputImage; } // ------------------------------------------------------------------------- @@ -99,17 +98,15 @@ _triggered_actionOpenInputImage( ) if( !( dialog.exec( ) ) ) return; - if( this->m_InputImage != NULL ) - delete this->m_InputImage; this->m_InputImage = NULL; unsigned int nFiles = dialog.selectedFiles( ).size( ); if( nFiles == 1 ) { std::string fname = dialog.selectedFiles( ).at( 0 ).toStdString( ); - TPlugin* reader = - dynamic_cast< TPlugin* >( - this->m_Plugins.CreateObject( this->m_BaseClasses[ "ImageReader" ] ) + TPlugin::Pointer reader = + this->m_Plugins.CreateProcessObject( + this->m_BaseClasses[ "ImageReader" ] ); TParameters reader_params = reader->GetDefaultParameters( ); @@ -132,7 +129,6 @@ _triggered_actionOpenInputImage( ) tr( "Error reading single image" ), tr( err.c_str( ) ) ); - delete reader; } else if( nFiles > 1 ) { @@ -154,7 +150,7 @@ _triggered_actionOpenInputImage( ) } // fi - if( this->m_InputImage != NULL ) + if( this->m_InputImage.IsNotNull( ) ) this->m_MPR->SetImage( this->m_InputImage->GetVTKImageData( ) ); } diff --git a/appli/ImageMPR/ImageMPR.h b/appli/ImageMPR/ImageMPR.h index 69b883a..c9bb20f 100644 --- a/appli/ImageMPR/ImageMPR.h +++ b/appli/ImageMPR/ImageMPR.h @@ -62,7 +62,7 @@ private: TStringMap m_BaseClasses; // Real data - TPluginImage* m_InputImage; + TPluginImage::Pointer m_InputImage; // Visualization stuff TMPR* m_MPR; diff --git a/appli/examples/example_LoadPlugins.cxx b/appli/examples/example_LoadPlugins.cxx index 383c85b..4bc43d0 100644 --- a/appli/examples/example_LoadPlugins.cxx +++ b/appli/examples/example_LoadPlugins.cxx @@ -25,7 +25,7 @@ int main( int argc, char* argv[] ) TClasses::const_iterator cIt = plugins.GetClasses( ).begin( ); TClasses::const_iterator end_cIt = plugins.GetClasses( ).end( ); for( ; cIt != end_cIt; ++cIt ) - std::cout << "\t:= " << cIt->first << std::endl; + std::cout << " := " << cIt->first << std::endl; std::cout << "---------------------------------------------" << std::endl; return( 0 ); diff --git a/appli/examples/example_MPR.cxx b/appli/examples/example_MPR.cxx index 3f11a4f..9a8865c 100644 --- a/appli/examples/example_MPR.cxx +++ b/appli/examples/example_MPR.cxx @@ -41,13 +41,10 @@ int main( int argc, char* argv[] ) // Create objects typedef cpPlugins::Interface::ProcessObject TProcessObject; typedef TProcessObject::TParameters TParameters; - cpPlugins::Interface::ProcessObject* reader; + cpPlugins::Interface::ProcessObject::Pointer reader; - reader = - dynamic_cast< TProcessObject* >( - plugins.CreateObject( "cpPlugins::Plugins::ImageReader" ) - ); - if( reader == NULL ) + reader = plugins.CreateProcessObject( "cpPlugins::Plugins::ImageReader" ); + if( reader.IsNull( ) ) { std::cerr << "No suitable reader found in plugins." << std::endl; return( 1 ); @@ -119,9 +116,6 @@ int main( int argc, char* argv[] ) window->Render( ); interactor->Start( ); - // Free memory - delete reader; - return( 0 ); } diff --git a/appli/examples/example_RGBImageToHSVChannels.cxx b/appli/examples/example_RGBImageToHSVChannels.cxx index 7266800..9a2a468 100644 --- a/appli/examples/example_RGBImageToHSVChannels.cxx +++ b/appli/examples/example_RGBImageToHSVChannels.cxx @@ -18,12 +18,9 @@ void SaveImage( TInterface& plugins, const std::string& fname, TDataObject* image ) { - cpPlugins::Interface::ProcessObject* writer; - writer = - dynamic_cast< TProcessObject* >( - plugins.CreateObject( "cpPlugins::Plugins::ImageWriter" ) - ); - if( writer == NULL ) + TProcessObject::Pointer writer; + writer = plugins.CreateProcessObject( "cpPlugins::Plugins::ImageWriter" ); + if( writer.IsNull( ) ) { std::cerr << "No suitable writer found in plugins." << std::endl; return; @@ -38,7 +35,6 @@ void SaveImage( std::string msg = writer->Update( ); if( msg != "" ) std::cerr << "ERROR: " << msg << std::endl; - delete writer; } // ------------------------------------------------------------------------- @@ -69,24 +65,18 @@ int main( int argc, char* argv[] ) plugins.Load( plugins_file ); // Create objects - cpPlugins::Interface::ProcessObject* reader; - cpPlugins::Interface::ProcessObject* filter; - - reader = - dynamic_cast< TProcessObject* >( - plugins.CreateObject( "cpPlugins::Plugins::ImageReader" ) - ); - if( reader == NULL ) + TProcessObject::Pointer reader; + TProcessObject::Pointer filter; + + reader = plugins.CreateProcessObject( "cpPlugins::Plugins::ImageReader" ); + if( reader.IsNull( ) ) { std::cerr << "No suitable reader found in plugins." << std::endl; return( 1 ); } // fi - filter = - dynamic_cast< TProcessObject* >( - plugins.CreateObject( "cpPlugins::Plugins::RGBImageToHSVChannelsFilter" ) - ); - if( filter == NULL ) + filter = plugins.CreateProcessObject( "cpPlugins::Plugins::RGBImageToHSVChannelsFilter" ); + if( filter.IsNull( ) ) { std::cerr << "No suitable filter found in plugins." << std::endl; return( 1 ); @@ -109,10 +99,6 @@ int main( int argc, char* argv[] ) SaveImage( plugins, output_saturation_image_file, filter->GetOutput( 1 ) ); SaveImage( plugins, output_value_image_file, filter->GetOutput( 2 ) ); - // Free memory - delete filter; - delete reader; - return( 0 ); } diff --git a/appli/examples/example_ReadImageSeriesWriteImage.cxx b/appli/examples/example_ReadImageSeriesWriteImage.cxx index cab163c..e2216ff 100644 --- a/appli/examples/example_ReadImageSeriesWriteImage.cxx +++ b/appli/examples/example_ReadImageSeriesWriteImage.cxx @@ -38,26 +38,20 @@ int main( int argc, char* argv[] ) // Create objects typedef cpPlugins::Interface::ProcessObject TProcessObject; typedef TProcessObject::TParameters TParameters; - cpPlugins::Interface::ProcessObject* reader; - cpPlugins::Interface::ProcessObject* writer; + cpPlugins::Interface::ProcessObject::Pointer reader; + cpPlugins::Interface::ProcessObject::Pointer writer; reader = - dynamic_cast< TProcessObject* >( - plugins.CreateObject( "cpPlugins::Plugins::ImageSeriesReader" ) - ); - if( reader == NULL ) + plugins.CreateProcessObject( "cpPlugins::Plugins::ImageSeriesReader" ); + if( reader.IsNull( ) ) { std::cerr << "No suitable reader found in plugins." << std::endl; return( 1 ); } // fi - writer = - dynamic_cast< TProcessObject* >( - plugins.CreateObject( "cpPlugins::Plugins::ImageWriter" ) - ); - if( writer == NULL ) + writer = plugins.CreateProcessObject( "cpPlugins::Plugins::ImageWriter" ); + if( writer.IsNull( ) ) { - delete reader; std::cerr << "No suitable writer found in plugins." << std::endl; return( 1 ); @@ -84,10 +78,6 @@ int main( int argc, char* argv[] ) if( msg != "" ) std::cerr << "ERROR: " << msg << std::endl; - // Free memory - delete writer; - delete reader; - return( 0 ); } diff --git a/appli/examples/example_ReadQuadEdgeMesh.cxx b/appli/examples/example_ReadQuadEdgeMesh.cxx index 655acad..94b6d6c 100644 --- a/appli/examples/example_ReadQuadEdgeMesh.cxx +++ b/appli/examples/example_ReadQuadEdgeMesh.cxx @@ -32,13 +32,10 @@ int main( int argc, char* argv[] ) // Create objects typedef cpPlugins::Interface::ProcessObject TProcessObject; typedef TProcessObject::TParameters TParameters; - cpPlugins::Interface::ProcessObject* reader; + cpPlugins::Interface::ProcessObject::Pointer reader; - reader = - dynamic_cast< TProcessObject* >( - plugins.CreateObject( "cpPlugins::Plugins::MeshReader" ) - ); - if( reader == NULL ) + reader = plugins.CreateProcessObject( "cpPlugins::Plugins::MeshReader" ); + if( reader.IsNull( ) ) { std::cerr << "No suitable reader found in plugins." << std::endl; return( 1 ); @@ -58,9 +55,6 @@ int main( int argc, char* argv[] ) if( msg != "" ) std::cerr << "ERROR: " << msg << std::endl; - // Free memory - delete reader; - return( 0 ); } diff --git a/appli/examples/example_ReadWriteImage.cxx b/appli/examples/example_ReadWriteImage.cxx index e07761c..d1419d9 100644 --- a/appli/examples/example_ReadWriteImage.cxx +++ b/appli/examples/example_ReadWriteImage.cxx @@ -34,26 +34,19 @@ int main( int argc, char* argv[] ) // Create objects typedef cpPlugins::Interface::ProcessObject TProcessObject; typedef TProcessObject::TParameters TParameters; - cpPlugins::Interface::ProcessObject* reader; - cpPlugins::Interface::ProcessObject* writer; - - reader = - dynamic_cast< TProcessObject* >( - plugins.CreateObject( "cpPlugins::Plugins::ImageReader" ) - ); - if( reader == NULL ) + cpPlugins::Interface::ProcessObject::Pointer reader; + cpPlugins::Interface::ProcessObject::Pointer writer; + + reader = plugins.CreateProcessObject( "cpPlugins::Plugins::ImageReader" ); + if( reader.IsNull( ) ) { std::cerr << "No suitable reader found in plugins." << std::endl; return( 1 ); } // fi - writer = - dynamic_cast< TProcessObject* >( - plugins.CreateObject( "cpPlugins::Plugins::ImageWriter" ) - ); - if( writer == NULL ) + writer = plugins.CreateProcessObject( "cpPlugins::Plugins::ImageWriter" ); + if( writer.IsNull( ) ) { - delete reader; std::cerr << "No suitable writer found in plugins." << std::endl; return( 1 ); @@ -80,10 +73,6 @@ int main( int argc, char* argv[] ) if( msg != "" ) std::cerr << "ERROR: " << msg << std::endl; - // Free memory - delete writer; - delete reader; - return( 0 ); } diff --git a/appli/examples/example_RenderQuadEdgeMesh.cxx b/appli/examples/example_RenderQuadEdgeMesh.cxx index db1e1ab..9fcd519 100644 --- a/appli/examples/example_RenderQuadEdgeMesh.cxx +++ b/appli/examples/example_RenderQuadEdgeMesh.cxx @@ -41,13 +41,10 @@ int main( int argc, char* argv[] ) // Create objects typedef cpPlugins::Interface::ProcessObject TProcessObject; typedef TProcessObject::TParameters TParameters; - cpPlugins::Interface::ProcessObject* reader; + cpPlugins::Interface::ProcessObject::Pointer reader; - reader = - dynamic_cast< TProcessObject* >( - plugins.CreateObject( "cpPlugins::Plugins::MeshReader" ) - ); - if( reader == NULL ) + reader = plugins.CreateProcessObject( "cpPlugins::Plugins::MeshReader" ); + if( reader.IsNull( ) ) { std::cerr << "No suitable reader found in plugins." << std::endl; return( 1 ); @@ -99,9 +96,6 @@ int main( int argc, char* argv[] ) window->Render( ); interactor->Start( ); - // Free memory - delete reader; - return( 0 ); } diff --git a/doc/uml/cpPlugins_classes.dia b/doc/uml/cpPlugins_classes.dia index 0331042..d5c0631 100644 Binary files a/doc/uml/cpPlugins_classes.dia and b/doc/uml/cpPlugins_classes.dia differ diff --git a/lib/cpPlugins/Interface/DataObject.cxx b/lib/cpPlugins/Interface/DataObject.cxx index 310cbb3..21b5f1d 100644 --- a/lib/cpPlugins/Interface/DataObject.cxx +++ b/lib/cpPlugins/Interface/DataObject.cxx @@ -1,42 +1,42 @@ #include // ------------------------------------------------------------------------- -cpPlugins::Interface::DataObject:: -DataObject( ) - : Superclass( ), - m_Source( NULL ) +std::string cpPlugins::Interface::DataObject:: +GetClassName( ) const { + return( "cpPlugins::Interface::DataObject" ); } // ------------------------------------------------------------------------- -cpPlugins::Interface::DataObject:: -~DataObject( ) +std::string cpPlugins::Interface::DataObject:: +GetClassType( ) const { + return( "DataObject" ); } // ------------------------------------------------------------------------- -std::string cpPlugins::Interface::DataObject:: -GetClassName( ) const +itk::DataObject* cpPlugins::Interface::DataObject:: +GetRealDataObject( ) const { - return( "cpPlugins::Interface::DataObject" ); + return( this->m_RealDataObject ); } // ------------------------------------------------------------------------- -itk::DataObject* cpPlugins::Interface::DataObject:: -GetDataObject( ) const +void cpPlugins::Interface::DataObject:: +SetRealDataObject( itk::DataObject* dobj ) { - return( this->m_DataObject ); + this->m_RealDataObject = dobj; } // ------------------------------------------------------------------------- -void cpPlugins::Interface::DataObject:: -SetDataObject( itk::DataObject* dobj ) +cpPlugins::Interface::Object* cpPlugins::Interface::DataObject:: +GetSource( ) { - this->m_DataObject = dobj; + return( this->m_Source ); } // ------------------------------------------------------------------------- -cpPlugins::Interface::ProcessObject* cpPlugins::Interface::DataObject:: +const cpPlugins::Interface::Object* cpPlugins::Interface::DataObject:: GetSource( ) const { return( this->m_Source ); @@ -44,7 +44,7 @@ GetSource( ) const // ------------------------------------------------------------------------- void cpPlugins::Interface::DataObject:: -SetSource( cpPlugins::Interface::ProcessObject* src ) +SetSource( cpPlugins::Interface::Object* src ) { this->m_Source = src; } @@ -53,12 +53,27 @@ SetSource( cpPlugins::Interface::ProcessObject* src ) void cpPlugins::Interface::DataObject:: DisconnectPipeline( ) { - if( this->m_DataObject.IsNotNull( ) ) + if( this->m_RealDataObject.IsNotNull( ) ) { - this->m_DataObject->DisconnectPipeline( ); - this->m_Source = NULL; + this->m_RealDataObject->DisconnectPipeline( ); + if( this->m_Source.IsNotNull( ) ) + this->m_Source->Delete( ); + this->Register( ); } // fi } +// ------------------------------------------------------------------------- +cpPlugins::Interface::DataObject:: +DataObject( ) + : Superclass( ) +{ +} + +// ------------------------------------------------------------------------- +cpPlugins::Interface::DataObject:: +~DataObject( ) +{ +} + // eof - $RCSfile$ diff --git a/lib/cpPlugins/Interface/DataObject.h b/lib/cpPlugins/Interface/DataObject.h index 3f561a2..c6a2129 100644 --- a/lib/cpPlugins/Interface/DataObject.h +++ b/lib/cpPlugins/Interface/DataObject.h @@ -11,34 +11,46 @@ namespace cpPlugins { namespace Interface { - class ProcessObject; - /** */ class cpPlugins_Interface_EXPORT DataObject : public Object { public: - typedef DataObject Self; - typedef Object Superclass; + typedef DataObject Self; + typedef Object Superclass; + typedef itk::SmartPointer< Self > Pointer; + typedef itk::SmartPointer< const Self > ConstPointer; public: - DataObject( ); - virtual ~DataObject( ); + itkNewMacro( Self ); + itkTypeMacro( DataObject, Object ); + public: virtual std::string GetClassName( ) const; + virtual std::string GetClassType( ) const; - itk::DataObject* GetDataObject( ) const; - virtual void SetDataObject( itk::DataObject* dobj ); + itk::DataObject* GetRealDataObject( ) const; + virtual void SetRealDataObject( itk::DataObject* dobj ); - ProcessObject* GetSource( ) const; - void SetSource( ProcessObject* src ); + Object* GetSource( ); + const Object* GetSource( ) const; + void SetSource( Object* src ); void DisconnectPipeline( ); protected: - itk::DataObject::Pointer m_DataObject; - ProcessObject* m_Source; + DataObject( ); + virtual ~DataObject( ); + + private: + // Purposely not implemented + DataObject( const Self& ); + Self& operator=( const Self& ); + + protected: + itk::DataObject::Pointer m_RealDataObject; + Object::Pointer m_Source; }; } // ecapseman diff --git a/lib/cpPlugins/Interface/FilterObject.cxx b/lib/cpPlugins/Interface/FilterObject.cxx new file mode 100644 index 0000000..b7b5218 --- /dev/null +++ b/lib/cpPlugins/Interface/FilterObject.cxx @@ -0,0 +1,30 @@ +#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( ) +{ +} + +// ------------------------------------------------------------------------- +cpPlugins::Interface::FilterObject:: +~FilterObject( ) +{ +} + +// eof - $RCSfile$ diff --git a/lib/cpPlugins/Interface/FilterObject.h b/lib/cpPlugins/Interface/FilterObject.h index e69de29..9f526c4 100644 --- a/lib/cpPlugins/Interface/FilterObject.h +++ b/lib/cpPlugins/Interface/FilterObject.h @@ -0,0 +1,48 @@ +#ifndef __CPPLUGINS__INTERFACE__FILTEROBJECT__H__ +#define __CPPLUGINS__INTERFACE__FILTEROBJECT__H__ + +#include +#include + +namespace cpPlugins +{ + namespace Interface + { + /** + */ + class cpPlugins_Interface_EXPORT FilterObject + : public ProcessObject + { + public: + typedef FilterObject Self; + typedef ProcessObject Superclass; + typedef itk::SmartPointer< Self > Pointer; + typedef itk::SmartPointer< const Self > ConstPointer; + + typedef Superclass::TParameter TParameter; + typedef Superclass::TParameters TParameters; + + public: + itkTypeMacro( FilterObject, ProcessObject ); + + public: + virtual std::string GetClassName( ) const; + virtual std::string GetClassType( ) const; + + protected: + FilterObject( ); + virtual ~FilterObject( ); + + private: + // Purposely not implemented + FilterObject( const Self& ); + Self& operator=( const Self& ); + }; + + } // ecapseman + +} // ecapseman + +#endif // __CPPLUGINS__INTERFACE__FILTEROBJECT__H__ + +// eof - $RCSfile$ diff --git a/lib/cpPlugins/Interface/Image.cxx b/lib/cpPlugins/Interface/Image.cxx index 52792d3..23cea6e 100644 --- a/lib/cpPlugins/Interface/Image.cxx +++ b/lib/cpPlugins/Interface/Image.cxx @@ -17,25 +17,9 @@ // ------------------------------------------------------------------------- #define cpPlugins_Image_RGB( p, d, o, f ) \ - if( \ - dynamic_cast< itk::Image< itk::RGBPixel< p >, d >* >( o ) != NULL \ - ) \ + if( dynamic_cast< itk::Image< itk::RGBPixel< p >, d >* >( o ) != NULL ) \ this->f< itk::RGBPixel< p >, d >( ) -// ------------------------------------------------------------------------- -cpPlugins::Interface::Image:: -Image( ) - : Superclass( ), - m_VTKImageData( NULL ) -{ -} - -// ------------------------------------------------------------------------- -cpPlugins::Interface::Image:: -~Image( ) -{ -} - // ------------------------------------------------------------------------- std::string cpPlugins::Interface::Image:: GetClassName( ) const @@ -45,13 +29,13 @@ GetClassName( ) const // ------------------------------------------------------------------------- void cpPlugins::Interface::Image:: -SetDataObject( itk::DataObject* dobj ) +SetRealDataObject( itk::DataObject* dobj ) { - this->Superclass::SetDataObject( dobj ); - - // WARNING: Only 2 and 3 dimensions at this moment - cpPlugins_Image_Dimension( 2, dobj, _ConnectToVTK_0 ); - else cpPlugins_Image_Dimension( 3, dobj, _ConnectToVTK_0 ); + 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 ); } // ------------------------------------------------------------------------- @@ -70,45 +54,59 @@ UpdateVTKImageData( ) this->m_VTKImageData->Modified( ); } +// ------------------------------------------------------------------------- +cpPlugins::Interface::Image:: +Image( ) + : Superclass( ), + m_VTKImageData( NULL ) +{ +} + +// ------------------------------------------------------------------------- +cpPlugins::Interface::Image:: +~Image( ) +{ +} + // ------------------------------------------------------------------------- template< unsigned int D > void cpPlugins::Interface::Image:: -_ConnectToVTK_0( ) +_VTK_0( ) { - itk::DataObject* dobj = this->Superclass::GetDataObject( ); - - cpPlugins_Image_Pixel( char, D, dobj, _ConnectToVTK_1 ); - else cpPlugins_Image_Pixel( short, D, dobj, _ConnectToVTK_1 ); - else cpPlugins_Image_Pixel( int, D, dobj, _ConnectToVTK_1 ); - else cpPlugins_Image_Pixel( long, D, dobj, _ConnectToVTK_1 ); - else cpPlugins_Image_Pixel( unsigned char, D, dobj, _ConnectToVTK_1 ); - else cpPlugins_Image_Pixel( unsigned short, D, dobj, _ConnectToVTK_1 ); - else cpPlugins_Image_Pixel( unsigned int, D, dobj, _ConnectToVTK_1 ); - else cpPlugins_Image_Pixel( unsigned long, D, dobj, _ConnectToVTK_1 ); - else cpPlugins_Image_Pixel( float, D, dobj, _ConnectToVTK_1 ); - else cpPlugins_Image_Pixel( double, D, dobj, _ConnectToVTK_1 ); - else cpPlugins_Image_RGB( char, D, dobj, _ConnectToVTK_1 ); - else cpPlugins_Image_RGB( short, D, dobj, _ConnectToVTK_1 ); - else cpPlugins_Image_RGB( int, D, dobj, _ConnectToVTK_1 ); - else cpPlugins_Image_RGB( long, D, dobj, _ConnectToVTK_1 ); - else cpPlugins_Image_RGB( unsigned char, D, dobj, _ConnectToVTK_1 ); - else cpPlugins_Image_RGB( unsigned short, D, dobj, _ConnectToVTK_1 ); - else cpPlugins_Image_RGB( unsigned int, D, dobj, _ConnectToVTK_1 ); - else cpPlugins_Image_RGB( unsigned long, D, dobj, _ConnectToVTK_1 ); - else cpPlugins_Image_RGB( float, D, dobj, _ConnectToVTK_1 ); - else cpPlugins_Image_RGB( double, D, dobj, _ConnectToVTK_1 ); + 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 ); } // ------------------------------------------------------------------------- template< class P, unsigned int D > void cpPlugins::Interface::Image:: -_ConnectToVTK_1( ) +_VTK_1( ) { typedef itk::Image< P, D > _TImage; typedef itk::ImageToVTKImageFilter< _TImage > _TFilter; _TImage* img = - dynamic_cast< _TImage* >( this->Superclass::GetDataObject( ) ); + dynamic_cast< _TImage* >( this->Superclass::GetRealDataObject( ) ); typename _TFilter::Pointer filter = _TFilter::New( ); filter->SetInput( img ); filter->Update( ); diff --git a/lib/cpPlugins/Interface/Image.h b/lib/cpPlugins/Interface/Image.h index f5454c4..4ba14cb 100644 --- a/lib/cpPlugins/Interface/Image.h +++ b/lib/cpPlugins/Interface/Image.h @@ -19,25 +19,36 @@ namespace cpPlugins : public DataObject { public: - typedef Image Self; - typedef DataObject Superclass; + typedef Image Self; + typedef DataObject Superclass; + typedef itk::SmartPointer< Self > Pointer; + typedef itk::SmartPointer< const Self > ConstPointer; public: - Image( ); - virtual ~Image( ); + itkNewMacro( Self ); + itkTypeMacro( Image, DataObject ); + public: virtual std::string GetClassName( ) const; - virtual void SetDataObject( itk::DataObject* dobj ); + virtual void SetRealDataObject( itk::DataObject* dobj ); vtkImageData* GetVTKImageData( ) const; void UpdateVTKImageData( ); protected: + Image( ); + virtual ~Image( ); + template< unsigned int D > - void _ConnectToVTK_0( ); + void _VTK_0( ); template< class P, unsigned int D > - void _ConnectToVTK_1( ); + void _VTK_1( ); + + private: + // Purposely not implemented + Image( const Self& ); + Self& operator=( const Self& ); protected: itk::ProcessObject::Pointer m_Image2VTKImageData; diff --git a/lib/cpPlugins/Interface/ImageSink.cxx b/lib/cpPlugins/Interface/ImageSink.cxx new file mode 100644 index 0000000..e22c14b --- /dev/null +++ b/lib/cpPlugins/Interface/ImageSink.cxx @@ -0,0 +1,30 @@ +#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( ) +{ +} + +// ------------------------------------------------------------------------- +cpPlugins::Interface::ImageSink:: +~ImageSink( ) +{ +} + +// eof - $RCSfile$ diff --git a/lib/cpPlugins/Interface/ImageSink.h b/lib/cpPlugins/Interface/ImageSink.h new file mode 100644 index 0000000..3895e21 --- /dev/null +++ b/lib/cpPlugins/Interface/ImageSink.h @@ -0,0 +1,48 @@ +#ifndef __CPPLUGINS__INTERFACE__IMAGESINK__H__ +#define __CPPLUGINS__INTERFACE__IMAGESINK__H__ + +#include +#include + +namespace cpPlugins +{ + namespace Interface + { + /** + */ + class cpPlugins_Interface_EXPORT ImageSink + : public SinkObject + { + public: + typedef ImageSink Self; + typedef SinkObject Superclass; + typedef itk::SmartPointer< Self > Pointer; + typedef itk::SmartPointer< const Self > ConstPointer; + + typedef Superclass::TParameter TParameter; + typedef Superclass::TParameters TParameters; + + public: + itkTypeMacro( ImageSink, SinkObject ); + + public: + virtual std::string GetClassName( ) const; + virtual std::string GetClassType( ) const; + + protected: + ImageSink( ); + virtual ~ImageSink( ); + + private: + // Purposely not implemented + ImageSink( const Self& ); + Self& operator=( const Self& ); + }; + + } // ecapseman + +} // ecapseman + +#endif // __CPPLUGINS__INTERFACE__IMAGESINK__H__ + +// eof - $RCSfile$ diff --git a/lib/cpPlugins/Interface/ImageSource.cxx b/lib/cpPlugins/Interface/ImageSource.cxx new file mode 100644 index 0000000..b58afd9 --- /dev/null +++ b/lib/cpPlugins/Interface/ImageSource.cxx @@ -0,0 +1,30 @@ +#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( ) +{ +} + +// ------------------------------------------------------------------------- +cpPlugins::Interface::ImageSource:: +~ImageSource( ) +{ +} + +// eof - $RCSfile$ diff --git a/lib/cpPlugins/Interface/ImageSource.h b/lib/cpPlugins/Interface/ImageSource.h new file mode 100644 index 0000000..2e8b80c --- /dev/null +++ b/lib/cpPlugins/Interface/ImageSource.h @@ -0,0 +1,48 @@ +#ifndef __CPPLUGINS__INTERFACE__IMAGESOURCE__H__ +#define __CPPLUGINS__INTERFACE__IMAGESOURCE__H__ + +#include +#include + +namespace cpPlugins +{ + namespace Interface + { + /** + */ + class cpPlugins_Interface_EXPORT ImageSource + : public SourceObject + { + public: + typedef ImageSource Self; + typedef SourceObject Superclass; + typedef itk::SmartPointer< Self > Pointer; + typedef itk::SmartPointer< const Self > ConstPointer; + + typedef Superclass::TParameter TParameter; + typedef Superclass::TParameters TParameters; + + public: + itkTypeMacro( ImageSource, SourceObject ); + + public: + virtual std::string GetClassName( ) const; + virtual std::string GetClassType( ) const; + + protected: + ImageSource( ); + virtual ~ImageSource( ); + + private: + // Purposely not implemented + ImageSource( const Self& ); + Self& operator=( const Self& ); + }; + + } // ecapseman + +} // ecapseman + +#endif // __CPPLUGINS__INTERFACE__IMAGESOURCE__H__ + +// eof - $RCSfile$ diff --git a/lib/cpPlugins/Interface/ImageToImageFilter.cxx b/lib/cpPlugins/Interface/ImageToImageFilter.cxx index 34fffdc..962c7a0 100644 --- a/lib/cpPlugins/Interface/ImageToImageFilter.cxx +++ b/lib/cpPlugins/Interface/ImageToImageFilter.cxx @@ -1,23 +1,30 @@ #include // ------------------------------------------------------------------------- -cpPlugins::Interface::ImageToImageFilter:: -ImageToImageFilter( ) - : Superclass( ) +std::string cpPlugins::Interface::ImageToImageFilter:: +GetClassName( ) const { + return( "cpPlugins::Interface::ImageToImageFilter" ); +} + +// ------------------------------------------------------------------------- +std::string cpPlugins::Interface::ImageToImageFilter:: +GetClassType( ) const +{ + return( "ImageToImageFilter" ); } // ------------------------------------------------------------------------- cpPlugins::Interface::ImageToImageFilter:: -~ImageToImageFilter( ) +ImageToImageFilter( ) + : Superclass( ) { } // ------------------------------------------------------------------------- -std::string cpPlugins::Interface::ImageToImageFilter:: -GetClassName( ) const +cpPlugins::Interface::ImageToImageFilter:: +~ImageToImageFilter( ) { - return( "cpPlugins::Interface::ImageToImageFilter" ); } // eof - $RCSfile$ diff --git a/lib/cpPlugins/Interface/ImageToImageFilter.h b/lib/cpPlugins/Interface/ImageToImageFilter.h index 962ec27..d7ac57a 100644 --- a/lib/cpPlugins/Interface/ImageToImageFilter.h +++ b/lib/cpPlugins/Interface/ImageToImageFilter.h @@ -2,7 +2,7 @@ #define __CPPLUGINS__INTERFACE__IMAGETOIMAGEFILTER__H__ #include -#include +#include namespace cpPlugins { @@ -11,20 +11,32 @@ namespace cpPlugins /** */ class cpPlugins_Interface_EXPORT ImageToImageFilter - : public ProcessObject + : public FilterObject { public: - typedef ImageToImageFilter Self; - typedef ProcessObject Superclass; + typedef ImageToImageFilter Self; + typedef FilterObject Superclass; + typedef itk::SmartPointer< Self > Pointer; + typedef itk::SmartPointer< const Self > ConstPointer; typedef Superclass::TParameter TParameter; typedef Superclass::TParameters TParameters; public: + itkTypeMacro( ImageToImageFilter, FilterObject ); + + public: + virtual std::string GetClassName( ) const; + virtual std::string GetClassType( ) const; + + protected: ImageToImageFilter( ); virtual ~ImageToImageFilter( ); - virtual std::string GetClassName( ) const; + private: + // Purposely not implemented + ImageToImageFilter( const Self& ); + Self& operator=( const Self& ); }; } // ecapseman diff --git a/lib/cpPlugins/Interface/ImageToMeshFilter.cxx b/lib/cpPlugins/Interface/ImageToMeshFilter.cxx index e5be566..b2a2a29 100644 --- a/lib/cpPlugins/Interface/ImageToMeshFilter.cxx +++ b/lib/cpPlugins/Interface/ImageToMeshFilter.cxx @@ -1,23 +1,30 @@ #include // ------------------------------------------------------------------------- -cpPlugins::Interface::ImageToMeshFilter:: -ImageToMeshFilter( ) - : Superclass( ) +std::string cpPlugins::Interface::ImageToMeshFilter:: +GetClassName( ) const { + return( "cpPlugins::Interface::ImageToMeshFilter" ); +} + +// ------------------------------------------------------------------------- +std::string cpPlugins::Interface::ImageToMeshFilter:: +GetClassType( ) const +{ + return( "ImageToMeshFilter" ); } // ------------------------------------------------------------------------- cpPlugins::Interface::ImageToMeshFilter:: -~ImageToMeshFilter( ) +ImageToMeshFilter( ) + : Superclass( ) { } // ------------------------------------------------------------------------- -std::string cpPlugins::Interface::ImageToMeshFilter:: -GetClassName( ) const +cpPlugins::Interface::ImageToMeshFilter:: +~ImageToMeshFilter( ) { - return( "cpPlugins::Interface::ImageToMeshFilter" ); } // eof - $RCSfile$ diff --git a/lib/cpPlugins/Interface/ImageToMeshFilter.h b/lib/cpPlugins/Interface/ImageToMeshFilter.h index dba9142..472f47a 100644 --- a/lib/cpPlugins/Interface/ImageToMeshFilter.h +++ b/lib/cpPlugins/Interface/ImageToMeshFilter.h @@ -2,7 +2,7 @@ #define __CPPLUGINS__INTERFACE__IMAGETOMESHFILTER__H__ #include -#include +#include namespace cpPlugins { @@ -11,20 +11,32 @@ namespace cpPlugins /** */ class cpPlugins_Interface_EXPORT ImageToMeshFilter - : public ProcessObject + : public FilterObject { public: - typedef ImageToMeshFilter Self; - typedef ProcessObject Superclass; + typedef ImageToMeshFilter Self; + typedef FilterObject Superclass; + typedef itk::SmartPointer< Self > Pointer; + typedef itk::SmartPointer< const Self > ConstPointer; typedef Superclass::TParameter TParameter; typedef Superclass::TParameters TParameters; public: + itkTypeMacro( ImageToMeshFilter, FilterObject ); + + public: + virtual std::string GetClassName( ) const; + virtual std::string GetClassType( ) const; + + protected: ImageToMeshFilter( ); virtual ~ImageToMeshFilter( ); - virtual std::string GetClassName( ) const; + private: + // Purposely not implemented + ImageToMeshFilter( const Self& ); + Self& operator=( const Self& ); }; } // ecapseman diff --git a/lib/cpPlugins/Interface/Instances_itkImage.cxx b/lib/cpPlugins/Interface/Instances_itkImage.cxx index cfa9b74..ba4d66e 100644 --- a/lib/cpPlugins/Interface/Instances_itkImage.cxx +++ b/lib/cpPlugins/Interface/Instances_itkImage.cxx @@ -3,67 +3,67 @@ #include // ------------------------------------------------------------------------- -#define cpPlugins_Interface_Instance_itkImage( t, d ) \ +#define cpPlugins_Instance_itkImage( t, d ) \ template class itk::Image< t, d >; \ template class itk::Image< itk::RGBPixel< t >, d > // ------------------------------------------------------------------------- -#define cpPlugins_Interface_Instance_itkImage2vtkImage( t, d ) \ +#define cpPlugins_Instance_itkImage2vtkImage( t, d ) \ template class itk::ImageToVTKImageFilter< itk::Image< t, d > >; \ template class \ itk::ImageToVTKImageFilter< itk::Image< itk::RGBPixel< t >, d > > // ------------------------------------------------------------------------- -#define cpPlugins_Interface_Instance_All_itkImage( t, d ) \ - cpPlugins_Interface_Instance_itkImage( t, d ); \ - cpPlugins_Interface_Instance_itkImage2vtkImage( t, d ) +#define cpPlugins_Instance_All_itkImage( t, d ) \ + cpPlugins_Instance_itkImage( t, d ); \ + cpPlugins_Instance_itkImage2vtkImage( t, d ) // ------------------------------------------------------------------------- // Images without vtk conversion -cpPlugins_Interface_Instance_itkImage( char, 1 ); -cpPlugins_Interface_Instance_itkImage( short, 1 ); -cpPlugins_Interface_Instance_itkImage( int, 1 ); -cpPlugins_Interface_Instance_itkImage( long, 1 ); -cpPlugins_Interface_Instance_itkImage( unsigned char, 1 ); -cpPlugins_Interface_Instance_itkImage( unsigned short, 1 ); -cpPlugins_Interface_Instance_itkImage( unsigned int, 1 ); -cpPlugins_Interface_Instance_itkImage( unsigned long, 1 ); -cpPlugins_Interface_Instance_itkImage( float, 1 ); -cpPlugins_Interface_Instance_itkImage( double, 1 ); +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 ); -cpPlugins_Interface_Instance_itkImage( char, 4 ); -cpPlugins_Interface_Instance_itkImage( short, 4 ); -cpPlugins_Interface_Instance_itkImage( int, 4 ); -cpPlugins_Interface_Instance_itkImage( long, 4 ); -cpPlugins_Interface_Instance_itkImage( unsigned char, 4 ); -cpPlugins_Interface_Instance_itkImage( unsigned short, 4 ); -cpPlugins_Interface_Instance_itkImage( unsigned int, 4 ); -cpPlugins_Interface_Instance_itkImage( unsigned long, 4 ); -cpPlugins_Interface_Instance_itkImage( float, 4 ); -cpPlugins_Interface_Instance_itkImage( double, 4 ); +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 ); // ------------------------------------------------------------------------- // Images with vtk conversion -cpPlugins_Interface_Instance_All_itkImage( char, 2 ); -cpPlugins_Interface_Instance_All_itkImage( short, 2 ); -cpPlugins_Interface_Instance_All_itkImage( int, 2 ); -cpPlugins_Interface_Instance_All_itkImage( long, 2 ); -cpPlugins_Interface_Instance_All_itkImage( unsigned char, 2 ); -cpPlugins_Interface_Instance_All_itkImage( unsigned short, 2 ); -cpPlugins_Interface_Instance_All_itkImage( unsigned int, 2 ); -cpPlugins_Interface_Instance_All_itkImage( unsigned long, 2 ); -cpPlugins_Interface_Instance_All_itkImage( float, 2 ); -cpPlugins_Interface_Instance_All_itkImage( double, 2 ); +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 ); -cpPlugins_Interface_Instance_All_itkImage( char, 3 ); -cpPlugins_Interface_Instance_All_itkImage( short, 3 ); -cpPlugins_Interface_Instance_All_itkImage( int, 3 ); -cpPlugins_Interface_Instance_All_itkImage( long, 3 ); -cpPlugins_Interface_Instance_All_itkImage( unsigned char, 3 ); -cpPlugins_Interface_Instance_All_itkImage( unsigned short, 3 ); -cpPlugins_Interface_Instance_All_itkImage( unsigned int, 3 ); -cpPlugins_Interface_Instance_All_itkImage( unsigned long, 3 ); -cpPlugins_Interface_Instance_All_itkImage( float, 3 ); -cpPlugins_Interface_Instance_All_itkImage( double, 3 ); +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 ); // eof - $RCSfile$ diff --git a/lib/cpPlugins/Interface/Interface.cxx b/lib/cpPlugins/Interface/Interface.cxx index 332ace5..e4160c6 100644 --- a/lib/cpPlugins/Interface/Interface.cxx +++ b/lib/cpPlugins/Interface/Interface.cxx @@ -31,7 +31,7 @@ GetClasses( ) const } // ------------------------------------------------------------------------- -cpPlugins::Interface::Object* cpPlugins::Interface::Interface:: +cpPlugins::Interface::Object::Pointer cpPlugins::Interface::Interface:: CreateObject( const std::string& name ) const { TClassesIterator cIt = this->m_Classes.find( name ); @@ -40,12 +40,23 @@ CreateObject( const std::string& name ) const ObjectProvider* provider = dynamic_cast< ObjectProvider* >( this->m_Providers[ cIt->second ] ); if( provider != NULL ) - return( dynamic_cast< Object* >( provider->create( ) ) ); + return( provider->create( ) ); } // fi return( NULL ); } +// ------------------------------------------------------------------------- +cpPlugins::Interface::ProcessObject::Pointer +cpPlugins::Interface::Interface:: +CreateProcessObject( const std::string& name ) const +{ + cpPlugins::Interface::Object::Pointer o = this->CreateObject( name ); + cpPlugins::Interface::ProcessObject::Pointer p = + dynamic_cast< cpPlugins::Interface::ProcessObject* >( o.GetPointer( ) ); + return( p ); +} + // ------------------------------------------------------------------------- bool cpPlugins::Interface::Interface:: Load( const std::string& path ) @@ -134,9 +145,8 @@ _LoadClasses( ) // Get reader provider for( unsigned int i = 0; i < this->m_Providers.size( ); ++i ) { - Object* dummy = this->m_Providers[ i ]->create( ); + Object::Pointer dummy = this->m_Providers[ i ]->create( ); this->m_Classes[ dummy->GetClassName( ) ] = i; - delete dummy; } // rof } diff --git a/lib/cpPlugins/Interface/Interface.h b/lib/cpPlugins/Interface/Interface.h index 1bade44..585e2d5 100644 --- a/lib/cpPlugins/Interface/Interface.h +++ b/lib/cpPlugins/Interface/Interface.h @@ -8,6 +8,7 @@ #include #include +#include namespace cpPlugins { @@ -31,7 +32,10 @@ namespace cpPlugins /// Plugin access TClasses& GetClasses( ); const TClasses& GetClasses( ) const; - Object* CreateObject( const std::string& name ) const; + Object::Pointer CreateObject( const std::string& name ) const; + ProcessObject::Pointer CreateProcessObject( + const std::string& name + ) const; /// Interface to PLUMA bool Load( const std::string& path ); diff --git a/lib/cpPlugins/Interface/Mesh.cxx b/lib/cpPlugins/Interface/Mesh.cxx index 8a184c9..9841f7e 100644 --- a/lib/cpPlugins/Interface/Mesh.cxx +++ b/lib/cpPlugins/Interface/Mesh.cxx @@ -5,21 +5,6 @@ #include #include -// ------------------------------------------------------------------------- -cpPlugins::Interface::Mesh:: -Mesh( ) - : Superclass( ), - m_Mapper( NULL ) -{ -} - -// ------------------------------------------------------------------------- -cpPlugins::Interface::Mesh:: -~Mesh( ) -{ - if( this->m_Mapper != NULL ) this->m_Mapper->Delete( ); -} - // ------------------------------------------------------------------------- std::string cpPlugins::Interface::Mesh:: GetClassName( ) const @@ -29,11 +14,11 @@ GetClassName( ) const // ------------------------------------------------------------------------- void cpPlugins::Interface::Mesh:: -SetDataObject( itk::DataObject* dobj ) +SetRealDataObject( itk::DataObject* dobj ) { - this->Superclass::SetDataObject( dobj ); - - // WARNING: Only 2 and 3 dimensions at this moment + this->Superclass::SetRealDataObject( dobj ); + + // 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; @@ -53,6 +38,21 @@ GetVTKMapper( ) const return( this->m_Mapper ); } +// ------------------------------------------------------------------------- +cpPlugins::Interface::Mesh:: +Mesh( ) + : Superclass( ), + m_Mapper( NULL ) +{ +} + +// ------------------------------------------------------------------------- +cpPlugins::Interface::Mesh:: +~Mesh( ) +{ + if( this->m_Mapper != NULL ) this->m_Mapper->Delete( ); +} + // ------------------------------------------------------------------------- template< class M > void cpPlugins::Interface::Mesh:: @@ -63,7 +63,7 @@ _Map( ) _TMapper; if( this->m_Mapper != NULL ) this->m_Mapper->Delete( ); - M* mesh = dynamic_cast< M* >( this->Superclass::GetDataObject( ) ); + M* mesh = dynamic_cast< M* >( this->Superclass::GetRealDataObject( ) ); _TMapper* mapper = _TMapper::New( ); mapper->SetInputData( mesh ); this->m_Mapper = mapper; diff --git a/lib/cpPlugins/Interface/Mesh.h b/lib/cpPlugins/Interface/Mesh.h index 805b8a1..241da35 100644 --- a/lib/cpPlugins/Interface/Mesh.h +++ b/lib/cpPlugins/Interface/Mesh.h @@ -19,22 +19,33 @@ namespace cpPlugins : public DataObject { public: - typedef Mesh Self; - typedef DataObject Superclass; + typedef Mesh Self; + typedef DataObject Superclass; + typedef itk::SmartPointer< Self > Pointer; + typedef itk::SmartPointer< const Self > ConstPointer; public: - Mesh( ); - virtual ~Mesh( ); + itkNewMacro( Self ); + itkTypeMacro( Mesh, DataObject ); + public: virtual std::string GetClassName( ) const; - virtual void SetDataObject( itk::DataObject* dobj ); + virtual void SetRealDataObject( itk::DataObject* dobj ); vtkMapper* GetVTKMapper( ) const; protected: + Mesh( ); + virtual ~Mesh( ); + template< class M > void _Map( ); + private: + // Purposely not implemented + Mesh( const Self& ); + Self& operator=( const Self& ); + protected: /* itk::ProcessObject::Pointer m_Mesh2VTKMeshData; diff --git a/lib/cpPlugins/Interface/MeshSink.cxx b/lib/cpPlugins/Interface/MeshSink.cxx new file mode 100644 index 0000000..dffacef --- /dev/null +++ b/lib/cpPlugins/Interface/MeshSink.cxx @@ -0,0 +1,30 @@ +#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( ) +{ +} + +// ------------------------------------------------------------------------- +cpPlugins::Interface::MeshSink:: +~MeshSink( ) +{ +} + +// eof - $RCSfile$ diff --git a/lib/cpPlugins/Interface/MeshSink.h b/lib/cpPlugins/Interface/MeshSink.h new file mode 100644 index 0000000..b110cb3 --- /dev/null +++ b/lib/cpPlugins/Interface/MeshSink.h @@ -0,0 +1,48 @@ +#ifndef __CPPLUGINS__INTERFACE__MESHSINK__H__ +#define __CPPLUGINS__INTERFACE__MESHSINK__H__ + +#include +#include + +namespace cpPlugins +{ + namespace Interface + { + /** + */ + class cpPlugins_Interface_EXPORT MeshSink + : public SinkObject + { + public: + typedef MeshSink Self; + typedef SinkObject Superclass; + typedef itk::SmartPointer< Self > Pointer; + typedef itk::SmartPointer< const Self > ConstPointer; + + typedef Superclass::TParameter TParameter; + typedef Superclass::TParameters TParameters; + + public: + itkTypeMacro( MeshSink, SinkObject ); + + public: + virtual std::string GetClassName( ) const; + virtual std::string GetClassType( ) const; + + protected: + MeshSink( ); + virtual ~MeshSink( ); + + private: + // Purposely not implemented + MeshSink( const Self& ); + Self& operator=( const Self& ); + }; + + } // ecapseman + +} // ecapseman + +#endif // __CPPLUGINS__INTERFACE__MESHSINK__H__ + +// eof - $RCSfile$ diff --git a/lib/cpPlugins/Interface/MeshSource.cxx b/lib/cpPlugins/Interface/MeshSource.cxx new file mode 100644 index 0000000..c608147 --- /dev/null +++ b/lib/cpPlugins/Interface/MeshSource.cxx @@ -0,0 +1,30 @@ +#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( ) +{ +} + +// ------------------------------------------------------------------------- +cpPlugins::Interface::MeshSource:: +~MeshSource( ) +{ +} + +// eof - $RCSfile$ diff --git a/lib/cpPlugins/Interface/MeshSource.h b/lib/cpPlugins/Interface/MeshSource.h new file mode 100644 index 0000000..9c5c3d2 --- /dev/null +++ b/lib/cpPlugins/Interface/MeshSource.h @@ -0,0 +1,48 @@ +#ifndef __CPPLUGINS__INTERFACE__MESHSOURCE__H__ +#define __CPPLUGINS__INTERFACE__MESHSOURCE__H__ + +#include +#include + +namespace cpPlugins +{ + namespace Interface + { + /** + */ + class cpPlugins_Interface_EXPORT MeshSource + : public SourceObject + { + public: + typedef MeshSource Self; + typedef SourceObject Superclass; + typedef itk::SmartPointer< Self > Pointer; + typedef itk::SmartPointer< const Self > ConstPointer; + + typedef Superclass::TParameter TParameter; + typedef Superclass::TParameters TParameters; + + public: + itkTypeMacro( MeshSource, SourceObject ); + + public: + virtual std::string GetClassName( ) const; + virtual std::string GetClassType( ) const; + + protected: + MeshSource( ); + virtual ~MeshSource( ); + + private: + // Purposely not implemented + MeshSource( const Self& ); + Self& operator=( const Self& ); + }; + + } // ecapseman + +} // ecapseman + +#endif // __CPPLUGINS__INTERFACE__MESHSOURCE__H__ + +// eof - $RCSfile$ diff --git a/lib/cpPlugins/Interface/MeshToImageFilter.cxx b/lib/cpPlugins/Interface/MeshToImageFilter.cxx new file mode 100644 index 0000000..804a381 --- /dev/null +++ b/lib/cpPlugins/Interface/MeshToImageFilter.cxx @@ -0,0 +1,30 @@ +#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( ) +{ +} + +// ------------------------------------------------------------------------- +cpPlugins::Interface::MeshToImageFilter:: +~MeshToImageFilter( ) +{ +} + +// eof - $RCSfile$ diff --git a/lib/cpPlugins/Interface/MeshToImageFilter.h b/lib/cpPlugins/Interface/MeshToImageFilter.h index e69de29..b6447d2 100644 --- a/lib/cpPlugins/Interface/MeshToImageFilter.h +++ b/lib/cpPlugins/Interface/MeshToImageFilter.h @@ -0,0 +1,48 @@ +#ifndef __CPPLUGINS__INTERFACE__MESHTOIMAGEFILTER__H__ +#define __CPPLUGINS__INTERFACE__MESHTOIMAGEFILTER__H__ + +#include +#include + +namespace cpPlugins +{ + namespace Interface + { + /** + */ + class cpPlugins_Interface_EXPORT MeshToImageFilter + : public FilterObject + { + public: + typedef MeshToImageFilter Self; + typedef FilterObject Superclass; + typedef itk::SmartPointer< Self > Pointer; + typedef itk::SmartPointer< const Self > ConstPointer; + + typedef Superclass::TParameter TParameter; + typedef Superclass::TParameters TParameters; + + public: + itkTypeMacro( MeshToImageFilter, FilterObject ); + + public: + virtual std::string GetClassName( ) const; + virtual std::string GetClassType( ) const; + + protected: + MeshToImageFilter( ); + virtual ~MeshToImageFilter( ); + + private: + // Purposely not implemented + MeshToImageFilter( const Self& ); + Self& operator=( const Self& ); + }; + + } // ecapseman + +} // ecapseman + +#endif // __CPPLUGINS__INTERFACE__MESHTOIMAGEFILTER__H__ + +// eof - $RCSfile$ diff --git a/lib/cpPlugins/Interface/MeshToMeshFilter.cxx b/lib/cpPlugins/Interface/MeshToMeshFilter.cxx new file mode 100644 index 0000000..4f5c76f --- /dev/null +++ b/lib/cpPlugins/Interface/MeshToMeshFilter.cxx @@ -0,0 +1,30 @@ +#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( ) +{ +} + +// ------------------------------------------------------------------------- +cpPlugins::Interface::MeshToMeshFilter:: +~MeshToMeshFilter( ) +{ +} + +// eof - $RCSfile$ diff --git a/lib/cpPlugins/Interface/MeshToMeshFilter.h b/lib/cpPlugins/Interface/MeshToMeshFilter.h index e69de29..7121c0e 100644 --- a/lib/cpPlugins/Interface/MeshToMeshFilter.h +++ b/lib/cpPlugins/Interface/MeshToMeshFilter.h @@ -0,0 +1,48 @@ +#ifndef __CPPLUGINS__INTERFACE__MESHTOMESHFILTER__H__ +#define __CPPLUGINS__INTERFACE__MESHTOMESHFILTER__H__ + +#include +#include + +namespace cpPlugins +{ + namespace Interface + { + /** + */ + class cpPlugins_Interface_EXPORT MeshToMeshFilter + : public FilterObject + { + public: + typedef MeshToMeshFilter Self; + typedef FilterObject Superclass; + typedef itk::SmartPointer< Self > Pointer; + typedef itk::SmartPointer< const Self > ConstPointer; + + typedef Superclass::TParameter TParameter; + typedef Superclass::TParameters TParameters; + + public: + itkTypeMacro( MeshToMeshFilter, FilterObject ); + + public: + virtual std::string GetClassName( ) const; + virtual std::string GetClassType( ) const; + + protected: + MeshToMeshFilter( ); + virtual ~MeshToMeshFilter( ); + + private: + // Purposely not implemented + MeshToMeshFilter( const Self& ); + Self& operator=( const Self& ); + }; + + } // ecapseman + +} // ecapseman + +#endif // __CPPLUGINS__INTERFACE__MESHTOMESHFILTER__H__ + +// eof - $RCSfile$ diff --git a/lib/cpPlugins/Interface/Object.cxx b/lib/cpPlugins/Interface/Object.cxx index c0418d3..3868b2c 100644 --- a/lib/cpPlugins/Interface/Object.cxx +++ b/lib/cpPlugins/Interface/Object.cxx @@ -1,22 +1,30 @@ #include // ------------------------------------------------------------------------- -cpPlugins::Interface::Object:: -Object( ) +std::string cpPlugins::Interface::Object:: +GetClassName( ) const { + return( "cpPlugins::Interface::Object" ); +} + +// ------------------------------------------------------------------------- +std::string cpPlugins::Interface::Object:: +GetClassType( ) const +{ + return( "Object" ); } // ------------------------------------------------------------------------- cpPlugins::Interface::Object:: -~Object( ) +Object( ) + : Superclass( ) { } // ------------------------------------------------------------------------- -std::string cpPlugins::Interface::Object:: -GetClassName( ) const +cpPlugins::Interface::Object:: +~Object( ) { - return( "cpPlugins::Interface::Object" ); } // ------------------------------------------------------------------------- diff --git a/lib/cpPlugins/Interface/Object.h b/lib/cpPlugins/Interface/Object.h index d4436f6..33cfdd7 100644 --- a/lib/cpPlugins/Interface/Object.h +++ b/lib/cpPlugins/Interface/Object.h @@ -3,8 +3,30 @@ #include #include +#include +#include #include +// ------------------------------------------------------------------------- +#define PLUMA_PROVIDER_HEADER_CPPLUGINS( TYPE ) \ + PLUMA_PROVIDER_HEADER_BEGIN( TYPE ) \ + virtual TYPE::Pointer create( ) const = 0; \ + PLUMA_PROVIDER_HEADER_END + +// ------------------------------------------------------------------------- +#define PLUMA_INHERIT_PROVIDER_CPPLUGINS( TYPE, SUPER ) \ + class TYPE##Provider \ + : public SUPER##Provider \ + { \ + public: \ + SUPER::Pointer create( ) const \ + { \ + TYPE::Pointer a = TYPE::New( ); \ + SUPER::Pointer b = a.GetPointer( ); \ + return( b ); \ + } \ + }; + namespace cpPlugins { namespace Interface @@ -12,16 +34,34 @@ namespace cpPlugins /** */ class cpPlugins_Interface_EXPORT Object + : public itk::Object { public: + typedef Object Self; + typedef itk::Object Superclass; + typedef itk::SmartPointer< Self > Pointer; + typedef itk::SmartPointer< const Self > ConstPointer; + + public: + itkNewMacro( Self ); + itkTypeMacro( Object, itkObject ); + + public: + virtual std::string GetClassName( ) const; + virtual std::string GetClassType( ) const; + + protected: Object( ); virtual ~Object( ); - virtual std::string GetClassName( ) const; + private: + // Purposely not implemented + Object( const Self& ); + Self& operator=( const Self& ); }; // TODO: doc - PLUMA_PROVIDER_HEADER( Object ); + PLUMA_PROVIDER_HEADER_CPPLUGINS( Object ); } // ecapseman diff --git a/lib/cpPlugins/Interface/ProcessObject.cxx b/lib/cpPlugins/Interface/ProcessObject.cxx index d1982b0..e05e7a8 100644 --- a/lib/cpPlugins/Interface/ProcessObject.cxx +++ b/lib/cpPlugins/Interface/ProcessObject.cxx @@ -1,25 +1,17 @@ #include // ------------------------------------------------------------------------- -cpPlugins::Interface::ProcessObject:: -ProcessObject( ) - : Superclass( ), - m_OutputsDisconnected( false ) -{ -} - -// ------------------------------------------------------------------------- -cpPlugins::Interface::ProcessObject:: -~ProcessObject( ) +std::string cpPlugins::Interface::ProcessObject:: +GetClassName( ) const { - this->_DeleteOutputs( ); + return( "cpPlugins::Interface::ProcessObject" ); } // ------------------------------------------------------------------------- std::string cpPlugins::Interface::ProcessObject:: -GetClassName( ) const +GetClassType( ) const { - return( "cpPlugins::Interface::ProcessObject" ); + return( "ProcessObject" ); } // ------------------------------------------------------------------------- @@ -35,6 +27,7 @@ void cpPlugins::Interface::ProcessObject:: SetParameters( const TParameters& params ) { this->m_Parameters = params; + this->Modified( ); } // ------------------------------------------------------------------------- @@ -56,27 +49,29 @@ void cpPlugins::Interface::ProcessObject:: SetNumberOfInputs( unsigned int n ) { this->m_Inputs.clear( ); - this->m_Inputs.resize( n, NULL ); + this->m_Inputs.resize( n ); + this->Modified( ); } // ------------------------------------------------------------------------- void cpPlugins::Interface::ProcessObject:: SetNumberOfOutputs( unsigned int n ) { - this->_DeleteOutputs( ); this->m_Outputs.clear( ); - this->m_Outputs.resize( n, NULL ); - this->m_OutputsDisconnected = false; + this->m_Outputs.resize( n ); + this->Modified( ); } // ------------------------------------------------------------------------- void cpPlugins::Interface::ProcessObject:: -SetInput( - unsigned int idx, const cpPlugins::Interface::DataObject* dobj - ) +SetInput( unsigned int idx, cpPlugins::Interface::DataObject* dobj ) { if( idx < this->m_Inputs.size( ) ) + { this->m_Inputs[ idx ] = dobj; + this->Modified( ); + + } // fi } // ------------------------------------------------------------------------- @@ -93,22 +88,20 @@ GetOutput( unsigned int idx ) std::string cpPlugins::Interface::ProcessObject:: Update( ) { - // Force upstream updates std::string r = ""; + + // Force upstream updates for( unsigned int i = 0; i < this->m_Inputs.size( ) && r == ""; ++i ) { - if( this->m_Inputs[ i ]->GetSource( ) != NULL ) - r = this->m_Inputs[ i ]->GetSource( )->Update( ); + Self* src = dynamic_cast< Self* >( this->m_Inputs[ i ]->GetSource( ) ); + if( src != NULL ) + r = src->Update( ); } // rof // Current update if( r == "" ) - { r = this->_GenerateData( ); - this->m_OutputsDisconnected = false; - - } // fi // Return error description, if any return( r ); @@ -118,18 +111,30 @@ Update( ) void cpPlugins::Interface::ProcessObject:: DisconnectOutputs( ) { - this->m_OutputsDisconnected = true; for( unsigned int idx = 0; idx < this->m_Outputs.size( ); ++idx ) - if( this->m_Outputs[ idx ] != NULL ) + if( this->m_Outputs[ idx ].IsNotNull( ) ) this->m_Outputs[ idx ]->DisconnectPipeline( ); } +// ------------------------------------------------------------------------- +cpPlugins::Interface::ProcessObject:: +ProcessObject( ) + : Superclass( ) +{ +} + +// ------------------------------------------------------------------------- +cpPlugins::Interface::ProcessObject:: +~ProcessObject( ) +{ +} + // ------------------------------------------------------------------------- itk::DataObject* cpPlugins::Interface::ProcessObject:: _GetInput( unsigned int idx ) { if( idx < this->m_Inputs.size( ) ) - return( this->m_Inputs[ idx ]->GetDataObject( ) ); + return( this->m_Inputs[ idx ]->GetRealDataObject( ) ); else return( NULL ); } @@ -139,18 +144,8 @@ void cpPlugins::Interface::ProcessObject:: _SetOutput( unsigned int idx, itk::DataObject* dobj ) { if( idx < this->m_Outputs.size( ) ) - if( this->m_Outputs[ idx ] != NULL ) - this->m_Outputs[ idx ]->SetDataObject( dobj ); -} - -// ------------------------------------------------------------------------- -void cpPlugins::Interface::ProcessObject:: -_DeleteOutputs( ) -{ - if( !( this->m_OutputsDisconnected ) ) - for( unsigned int idx = 0; idx < this->m_Outputs.size( ); ++idx ) - if( this->m_Outputs[ idx ] != NULL ) - delete this->m_Outputs[ idx ]; + 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 a5404a8..f4c80ae 100644 --- a/lib/cpPlugins/Interface/ProcessObject.h +++ b/lib/cpPlugins/Interface/ProcessObject.h @@ -3,7 +3,6 @@ #include #include -#include #include #include #include @@ -13,25 +12,26 @@ namespace cpPlugins { namespace Interface { - class DataObject; - /** */ class cpPlugins_Interface_EXPORT ProcessObject : public Object { public: - typedef ProcessObject Self; - typedef Object Superclass; + typedef ProcessObject Self; + typedef Object Superclass; + typedef itk::SmartPointer< Self > Pointer; + typedef itk::SmartPointer< const Self > ConstPointer; typedef std::pair< std::string, std::string > TParameter; typedef std::map< std::string, TParameter > TParameters; public: - ProcessObject( ); - virtual ~ProcessObject( ); + itkTypeMacro( ProcessObject, Object ); + public: virtual std::string GetClassName( ) const; + virtual std::string GetClassType( ) const; virtual const TParameters& GetDefaultParameters( ) const; virtual void SetParameters( const TParameters& params ); @@ -41,40 +41,42 @@ namespace cpPlugins virtual void SetNumberOfInputs( unsigned int n ); virtual void SetNumberOfOutputs( unsigned int n ); - virtual void SetInput( unsigned int idx, const DataObject* dobj ); + virtual void SetInput( unsigned int idx, DataObject* dobj ); virtual DataObject* GetOutput( unsigned int idx ); virtual std::string Update( ); virtual void DisconnectOutputs( ); protected: + ProcessObject( ); + virtual ~ProcessObject( ); + virtual itk::DataObject* _GetInput( unsigned int idx ); virtual void _SetOutput( unsigned int idx, itk::DataObject* dobj ); - virtual void _DeleteOutputs( ); template< class O > void _MakeOutput( unsigned int idx ) { if( idx >= this->m_Outputs.size( ) ) return; - - if( !( this->m_OutputsDisconnected ) ) - if( this->m_Outputs[ idx ] != NULL ) - delete this->m_Outputs[ idx ]; - - this->m_Outputs[ idx ] = new O( ); + this->m_Outputs[ idx ] = O::New( ); this->m_Outputs[ idx ]->SetSource( this ); } virtual std::string _GenerateData( ) = 0; + private: + // Purposely not implemented + ProcessObject( const Self& ); + Self& operator=( const Self& ); + protected: + itk::ProcessObject::Pointer m_RealProcessObject; TParameters m_DefaultParameters; TParameters m_Parameters; - std::vector< const DataObject* > m_Inputs; - std::vector< DataObject* > m_Outputs; - bool m_OutputsDisconnected; + std::vector< DataObject::Pointer > m_Inputs; + std::vector< DataObject::Pointer > m_Outputs; }; } // ecapseman diff --git a/lib/cpPlugins/Interface/SinkObject.cxx b/lib/cpPlugins/Interface/SinkObject.cxx index c0ff636..309a3d1 100644 --- a/lib/cpPlugins/Interface/SinkObject.cxx +++ b/lib/cpPlugins/Interface/SinkObject.cxx @@ -1,5 +1,19 @@ #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( ) @@ -14,11 +28,4 @@ cpPlugins::Interface::SinkObject:: { } -// ------------------------------------------------------------------------- -std::string cpPlugins::Interface::SinkObject:: -GetClassName( ) const -{ - return( "cpPlugins::Interface::SinkObject" ); -} - // eof - $RCSfile$ diff --git a/lib/cpPlugins/Interface/SinkObject.h b/lib/cpPlugins/Interface/SinkObject.h index 7caf70e..52723d1 100644 --- a/lib/cpPlugins/Interface/SinkObject.h +++ b/lib/cpPlugins/Interface/SinkObject.h @@ -14,17 +14,29 @@ namespace cpPlugins : public ProcessObject { public: - typedef SinkObject Self; - typedef ProcessObject Superclass; + typedef SinkObject Self; + typedef ProcessObject Superclass; + typedef itk::SmartPointer< Self > Pointer; + typedef itk::SmartPointer< const Self > ConstPointer; typedef Superclass::TParameter TParameter; typedef Superclass::TParameters TParameters; public: + itkTypeMacro( SinkObject, ProcessObject ); + + public: + virtual std::string GetClassName( ) const; + virtual std::string GetClassType( ) const; + + protected: SinkObject( ); virtual ~SinkObject( ); - virtual std::string GetClassName( ) const; + private: + // Purposely not implemented + SinkObject( const Self& ); + Self& operator=( const Self& ); }; } // ecapseman diff --git a/lib/cpPlugins/Interface/SourceObject.cxx b/lib/cpPlugins/Interface/SourceObject.cxx index b4499db..9ad0878 100644 --- a/lib/cpPlugins/Interface/SourceObject.cxx +++ b/lib/cpPlugins/Interface/SourceObject.cxx @@ -1,5 +1,19 @@ #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( ) @@ -14,11 +28,4 @@ cpPlugins::Interface::SourceObject:: { } -// ------------------------------------------------------------------------- -std::string cpPlugins::Interface::SourceObject:: -GetClassName( ) const -{ - return( "cpPlugins::Interface::SourceObject" ); -} - // eof - $RCSfile$ diff --git a/lib/cpPlugins/Interface/SourceObject.h b/lib/cpPlugins/Interface/SourceObject.h index 22914b9..0c036ce 100644 --- a/lib/cpPlugins/Interface/SourceObject.h +++ b/lib/cpPlugins/Interface/SourceObject.h @@ -14,17 +14,29 @@ namespace cpPlugins : public ProcessObject { public: - typedef SourceObject Self; - typedef ProcessObject Superclass; + typedef SourceObject Self; + typedef ProcessObject Superclass; + typedef itk::SmartPointer< Self > Pointer; + typedef itk::SmartPointer< const Self > ConstPointer; typedef Superclass::TParameter TParameter; typedef Superclass::TParameters TParameters; public: + itkTypeMacro( SourceObject, ProcessObject ); + + public: + virtual std::string GetClassName( ) const; + virtual std::string GetClassType( ) const; + + protected: SourceObject( ); virtual ~SourceObject( ); - virtual std::string GetClassName( ) const; + private: + // Purposely not implemented + SourceObject( const Self& ); + Self& operator=( const Self& ); }; } // ecapseman diff --git a/lib/cpPlugins/Plugins/ImageReader.cxx b/lib/cpPlugins/Plugins/ImageReader.cxx index df0f1e6..0aa4bfc 100644 --- a/lib/cpPlugins/Plugins/ImageReader.cxx +++ b/lib/cpPlugins/Plugins/ImageReader.cxx @@ -7,6 +7,13 @@ #include #include +// ------------------------------------------------------------------------- +std::string cpPlugins::Plugins::ImageReader:: +GetClassName( ) const +{ + return( "cpPlugins::Plugins::ImageReader" ); +} + // ------------------------------------------------------------------------- cpPlugins::Plugins::ImageReader:: ImageReader( ) @@ -28,13 +35,6 @@ cpPlugins::Plugins::ImageReader:: { } -// ------------------------------------------------------------------------- -std::string cpPlugins::Plugins::ImageReader:: -GetClassName( ) const -{ - return( "cpPlugins::Plugins::ImageReader" ); -} - // ------------------------------------------------------------------------- std::string cpPlugins::Plugins::ImageReader:: _GenerateData( ) @@ -136,11 +136,12 @@ _GD1( ) typedef itk::ImageFileReader< _TImage > _TReader; _TReader* reader = - dynamic_cast< _TReader* >( this->m_Reader.GetPointer( ) ); + dynamic_cast< _TReader* >( this->m_RealProcessObject.GetPointer( ) ); if( reader == NULL ) { - this->m_Reader = _TReader::New( ); - reader = dynamic_cast< _TReader* >( this->m_Reader.GetPointer( ) ); + this->m_RealProcessObject = _TReader::New( ); + reader = + dynamic_cast< _TReader* >( this->m_RealProcessObject.GetPointer( ) ); } // fi reader->SetFileName( fIt->second.second ); diff --git a/lib/cpPlugins/Plugins/ImageReader.h b/lib/cpPlugins/Plugins/ImageReader.h index 39d243b..2c73d70 100644 --- a/lib/cpPlugins/Plugins/ImageReader.h +++ b/lib/cpPlugins/Plugins/ImageReader.h @@ -2,7 +2,7 @@ #define __CPPLUGINS__PLUGINS__IMAGEREADER__H__ #include -#include +#include #include namespace cpPlugins @@ -12,22 +12,28 @@ namespace cpPlugins /** */ class cpPlugins_EXPORT ImageReader - : public cpPlugins::Interface::SourceObject + : public cpPlugins::Interface::ImageSource { public: - typedef ImageReader Self; - typedef cpPlugins::Interface::SourceObject Superclass; + typedef ImageReader Self; + typedef cpPlugins::Interface::ImageSource Superclass; + typedef itk::SmartPointer< Self > Pointer; + typedef itk::SmartPointer< const Self > ConstPointer; typedef Superclass::TParameter TParameter; typedef Superclass::TParameters TParameters; public: - ImageReader( ); - virtual ~ImageReader( ); + itkNewMacro( Self ); + itkTypeMacro( ImageReader, cpPluginsInterfaceImageSource ); + public: virtual std::string GetClassName( ) const; protected: + ImageReader( ); + virtual ~ImageReader( ); + virtual std::string _GenerateData( ); template< unsigned int D > @@ -36,12 +42,17 @@ namespace cpPlugins template< class P, unsigned int D > std::string _GD1( ); - protected: - itk::ProcessObject::Pointer m_Reader; + private: + // Purposely not implemented + ImageReader( const Self& ); + Self& operator=( const Self& ); }; // --------------------------------------------------------------------- - PLUMA_INHERIT_PROVIDER( ImageReader, cpPlugins::Interface::Object ); + PLUMA_INHERIT_PROVIDER_CPPLUGINS( + ImageReader, + cpPlugins::Interface::Object + ); } // ecapseman diff --git a/lib/cpPlugins/Plugins/ImageSeriesReader.cxx b/lib/cpPlugins/Plugins/ImageSeriesReader.cxx index 416352a..d6fbfa6 100644 --- a/lib/cpPlugins/Plugins/ImageSeriesReader.cxx +++ b/lib/cpPlugins/Plugins/ImageSeriesReader.cxx @@ -10,6 +10,13 @@ #include #include +// ------------------------------------------------------------------------- +std::string cpPlugins::Plugins::ImageSeriesReader:: +GetClassName( ) const +{ + return( "cpPlugins::Plugins::ImageSeriesReader" ); +} + // ------------------------------------------------------------------------- cpPlugins::Plugins::ImageSeriesReader:: ImageSeriesReader( ) @@ -31,13 +38,6 @@ cpPlugins::Plugins::ImageSeriesReader:: { } -// ------------------------------------------------------------------------- -std::string cpPlugins::Plugins::ImageSeriesReader:: -GetClassName( ) const -{ - return( "cpPlugins::Plugins::ImageSeriesReader" ); -} - // ------------------------------------------------------------------------- std::string cpPlugins::Plugins::ImageSeriesReader:: _GenerateData( ) @@ -144,11 +144,12 @@ _GD1( ) typedef itk::ImageSeriesReader< _TImage > _TReader; _TReader* reader = - dynamic_cast< _TReader* >( this->m_Reader.GetPointer( ) ); + dynamic_cast< _TReader* >( this->m_RealProcessObject.GetPointer( ) ); if( reader == NULL ) { - this->m_Reader = _TReader::New( ); - reader = dynamic_cast< _TReader* >( this->m_Reader.GetPointer( ) ); + this->m_RealProcessObject = _TReader::New( ); + reader = + dynamic_cast< _TReader* >( this->m_RealProcessObject.GetPointer( ) ); } // fi std::set< std::string >::const_iterator fnIt = filenames.begin( ); diff --git a/lib/cpPlugins/Plugins/ImageSeriesReader.h b/lib/cpPlugins/Plugins/ImageSeriesReader.h index 6ddf039..9bd9bc2 100644 --- a/lib/cpPlugins/Plugins/ImageSeriesReader.h +++ b/lib/cpPlugins/Plugins/ImageSeriesReader.h @@ -2,7 +2,7 @@ #define __CPPLUGINS__PLUGINS__IMAGESERIESREADER__H__ #include -#include +#include #include namespace cpPlugins @@ -12,22 +12,27 @@ namespace cpPlugins /** */ class cpPlugins_EXPORT ImageSeriesReader - : public cpPlugins::Interface::SourceObject + : public cpPlugins::Interface::ImageSource { public: - typedef ImageSeriesReader Self; - typedef cpPlugins::Interface::SourceObject Superclass; + typedef ImageSeriesReader Self; + typedef cpPlugins::Interface::ImageSource Superclass; + typedef itk::SmartPointer< Self > Pointer; + typedef itk::SmartPointer< const Self > ConstPointer; typedef Superclass::TParameter TParameter; typedef Superclass::TParameters TParameters; public: - ImageSeriesReader( ); - virtual ~ImageSeriesReader( ); + itkNewMacro( Self ); + itkTypeMacro( ImageSeriesReader, cpPluginsInterfaceImageSource ); + public: virtual std::string GetClassName( ) const; protected: + ImageSeriesReader( ); + virtual ~ImageSeriesReader( ); virtual std::string _GenerateData( ); @@ -37,12 +42,17 @@ namespace cpPlugins template< class P, unsigned int D > std::string _GD1( ); - protected: - itk::ProcessObject::Pointer m_Reader; + private: + // Purposely not implemented + ImageSeriesReader( const Self& ); + Self& operator=( const Self& ); }; // --------------------------------------------------------------------- - PLUMA_INHERIT_PROVIDER( ImageSeriesReader, cpPlugins::Interface::Object ); + PLUMA_INHERIT_PROVIDER_CPPLUGINS( + ImageSeriesReader, + cpPlugins::Interface::Object + ); } // ecapseman diff --git a/lib/cpPlugins/Plugins/ImageWriter.cxx b/lib/cpPlugins/Plugins/ImageWriter.cxx index 41fdb30..aea4a21 100644 --- a/lib/cpPlugins/Plugins/ImageWriter.cxx +++ b/lib/cpPlugins/Plugins/ImageWriter.cxx @@ -23,6 +23,13 @@ ) \ r = this->f< itk::RGBPixel< p >, d >( ) +// ------------------------------------------------------------------------- +std::string cpPlugins::Plugins::ImageWriter:: +GetClassName( ) const +{ + return( "cpPlugins::Plugins::ImageWriter" ); +} + // ------------------------------------------------------------------------- cpPlugins::Plugins::ImageWriter:: ImageWriter( ) @@ -40,13 +47,6 @@ cpPlugins::Plugins::ImageWriter:: { } -// ------------------------------------------------------------------------- -std::string cpPlugins::Plugins::ImageWriter:: -GetClassName( ) const -{ - return( "cpPlugins::Plugins::ImageWriter" ); -} - // ------------------------------------------------------------------------- std::string cpPlugins::Plugins::ImageWriter:: _GenerateData( ) @@ -99,7 +99,7 @@ std::string cpPlugins::Plugins::ImageWriter:: _GD1( ) { typedef itk::Image< P, D > _TImage; - typedef itk::ImageFileWriter< _TImage > _TImageWriter; + typedef itk::ImageFileWriter< _TImage > _TWriter; TParameters::const_iterator fIt; @@ -108,12 +108,13 @@ _GD1( ) if( fIt == this->m_Parameters.end( ) ) fIt = this->m_DefaultParameters.find( "FileName" ); - _TImageWriter* writer = - dynamic_cast< _TImageWriter* >( this->m_Writer.GetPointer( ) ); + _TWriter* writer = + dynamic_cast< _TWriter* >( this->m_RealProcessObject.GetPointer( ) ); if( writer == NULL ) { - this->m_Writer = _TImageWriter::New( ); - writer = dynamic_cast< _TImageWriter* >( this->m_Writer.GetPointer( ) ); + this->m_RealProcessObject = _TWriter::New( ); + writer = + dynamic_cast< _TWriter* >( this->m_RealProcessObject.GetPointer( ) ); } // fi writer->SetFileName( fIt->second.second ); diff --git a/lib/cpPlugins/Plugins/ImageWriter.h b/lib/cpPlugins/Plugins/ImageWriter.h index 57f15db..1dcd98f 100644 --- a/lib/cpPlugins/Plugins/ImageWriter.h +++ b/lib/cpPlugins/Plugins/ImageWriter.h @@ -2,7 +2,7 @@ #define __CPPLUGINS__PLUGINS__IMAGEWRITER__H__ #include -#include +#include #include namespace cpPlugins @@ -12,22 +12,28 @@ namespace cpPlugins /** */ class cpPlugins_EXPORT ImageWriter - : public cpPlugins::Interface::SinkObject + : public cpPlugins::Interface::ImageSink { public: - typedef ImageWriter Self; - typedef cpPlugins::Interface::SinkObject Superclass; + typedef ImageWriter Self; + typedef cpPlugins::Interface::ImageSink Superclass; + typedef itk::SmartPointer< Self > Pointer; + typedef itk::SmartPointer< const Self > ConstPointer; typedef Superclass::TParameter TParameter; typedef Superclass::TParameters TParameters; public: - ImageWriter( ); - virtual ~ImageWriter( ); + itkNewMacro( Self ); + itkTypeMacro( ImageWriter, cpPluginsInterfaceImageSink ); + public: virtual std::string GetClassName( ) const; protected: + ImageWriter( ); + virtual ~ImageWriter( ); + virtual std::string _GenerateData( ); template< unsigned int D > @@ -36,12 +42,17 @@ namespace cpPlugins template< class P, unsigned int D > std::string _GD1( ); - protected: - itk::ProcessObject::Pointer m_Writer; + private: + // Purposely not implemented + ImageWriter( const Self& ); + Self& operator=( const Self& ); }; // --------------------------------------------------------------------- - PLUMA_INHERIT_PROVIDER( ImageWriter, cpPlugins::Interface::Object ); + PLUMA_INHERIT_PROVIDER_CPPLUGINS( + ImageWriter, + cpPlugins::Interface::Object + ); } // ecapseman diff --git a/lib/cpPlugins/Plugins/MarchingCubes.cxx b/lib/cpPlugins/Plugins/MarchingCubes.cxx index 3204033..12aad40 100644 --- a/lib/cpPlugins/Plugins/MarchingCubes.cxx +++ b/lib/cpPlugins/Plugins/MarchingCubes.cxx @@ -8,6 +8,13 @@ #include #include +// ------------------------------------------------------------------------- +std::string cpPlugins::Plugins::MarchingCubes:: +GetClassName( ) const +{ + return( "cpPlugins::Plugins::MarchingCubes" ); +} + // ------------------------------------------------------------------------- cpPlugins::Plugins::MarchingCubes:: MarchingCubes( ) @@ -32,13 +39,6 @@ cpPlugins::Plugins::MarchingCubes:: { } -// ------------------------------------------------------------------------- -std::string cpPlugins::Plugins::MarchingCubes:: -GetClassName( ) const -{ - return( "cpPlugins::Plugins::MarchingCubes" ); -} - // ------------------------------------------------------------------------- std::string cpPlugins::Plugins::MarchingCubes:: _GenerateData( ) diff --git a/lib/cpPlugins/Plugins/MarchingCubes.h b/lib/cpPlugins/Plugins/MarchingCubes.h index c691f8f..cf616b0 100644 --- a/lib/cpPlugins/Plugins/MarchingCubes.h +++ b/lib/cpPlugins/Plugins/MarchingCubes.h @@ -17,17 +17,23 @@ namespace cpPlugins public: typedef MarchingCubes Self; typedef cpPlugins::Interface::ImageToMeshFilter Superclass; + typedef itk::SmartPointer< Self > Pointer; + typedef itk::SmartPointer< const Self > ConstPointer; typedef Superclass::TParameter TParameter; typedef Superclass::TParameters TParameters; public: - MarchingCubes( ); - virtual ~MarchingCubes( ); + itkNewMacro( Self ); + itkTypeMacro( MarchingCubes, cpPluginsInterfaceImageToMeshFilter ); + public: virtual std::string GetClassName( ) const; protected: + MarchingCubes( ); + virtual ~MarchingCubes( ); + virtual std::string _GenerateData( ); template< unsigned int D > @@ -36,14 +42,17 @@ namespace cpPlugins template< class P, unsigned int D > std::string _GD1( ); - protected: - /* - itk::ProcessObject::Pointer m_Reader; - */ + private: + // Purposely not implemented + MarchingCubes( const Self& ); + Self& operator=( const Self& ); }; // --------------------------------------------------------------------- - PLUMA_INHERIT_PROVIDER( MarchingCubes, cpPlugins::Interface::Object ); + PLUMA_INHERIT_PROVIDER_CPPLUGINS( + MarchingCubes, + cpPlugins::Interface::Object + ); } // ecapseman diff --git a/lib/cpPlugins/Plugins/MeshReader.cxx b/lib/cpPlugins/Plugins/MeshReader.cxx index 322e49c..b219899 100644 --- a/lib/cpPlugins/Plugins/MeshReader.cxx +++ b/lib/cpPlugins/Plugins/MeshReader.cxx @@ -4,6 +4,13 @@ #include #include +// ------------------------------------------------------------------------- +std::string cpPlugins::Plugins::MeshReader:: +GetClassName( ) const +{ + return( "cpPlugins::Plugins::MeshReader" ); +} + // ------------------------------------------------------------------------- cpPlugins::Plugins::MeshReader:: MeshReader( ) @@ -24,13 +31,6 @@ cpPlugins::Plugins::MeshReader:: { } -// ------------------------------------------------------------------------- -std::string cpPlugins::Plugins::MeshReader:: -GetClassName( ) const -{ - return( "cpPlugins::Plugins::MeshReader" ); -} - // ------------------------------------------------------------------------- std::string cpPlugins::Plugins::MeshReader:: _GenerateData( ) @@ -85,11 +85,12 @@ _GD1( ) typedef IO::MeshReader< _TMesh > _TReader; _TReader* reader = - dynamic_cast< _TReader* >( this->m_Reader.GetPointer( ) ); + dynamic_cast< _TReader* >( this->m_RealProcessObject.GetPointer( ) ); if( reader == NULL ) { - this->m_Reader = _TReader::New( ); - reader = dynamic_cast< _TReader* >( this->m_Reader.GetPointer( ) ); + this->m_RealProcessObject = _TReader::New( ); + reader = + dynamic_cast< _TReader* >( this->m_RealProcessObject.GetPointer( ) ); } // fi reader->SetFileName( fIt->second.second ); diff --git a/lib/cpPlugins/Plugins/MeshReader.h b/lib/cpPlugins/Plugins/MeshReader.h index 968c4ac..bfd9426 100644 --- a/lib/cpPlugins/Plugins/MeshReader.h +++ b/lib/cpPlugins/Plugins/MeshReader.h @@ -2,7 +2,7 @@ #define __CPPLUGINS__PLUGINS__MESHREADER__H__ #include -#include +#include #include namespace cpPlugins @@ -12,22 +12,28 @@ namespace cpPlugins /** */ class cpPlugins_EXPORT MeshReader - : public cpPlugins::Interface::SourceObject + : public cpPlugins::Interface::MeshSource { public: - typedef MeshReader Self; - typedef cpPlugins::Interface::SourceObject Superclass; + typedef MeshReader Self; + typedef cpPlugins::Interface::MeshSource Superclass; + typedef itk::SmartPointer< Self > Pointer; + typedef itk::SmartPointer< const Self > ConstPointer; typedef Superclass::TParameter TParameter; typedef Superclass::TParameters TParameters; public: - MeshReader( ); - virtual ~MeshReader( ); + itkNewMacro( Self ); + itkTypeMacro( MeshReader, cpPluginsInterfaceMeshSource ); + public: virtual std::string GetClassName( ) const; protected: + MeshReader( ); + virtual ~MeshReader( ); + virtual std::string _GenerateData( ); template< unsigned int D > @@ -36,12 +42,17 @@ namespace cpPlugins template< class P, unsigned int D > std::string _GD1( ); - protected: - itk::ProcessObject::Pointer m_Reader; + private: + // Purposely not implemented + MeshReader( const Self& ); + Self& operator=( const Self& ); }; // --------------------------------------------------------------------- - PLUMA_INHERIT_PROVIDER( MeshReader, cpPlugins::Interface::Object ); + PLUMA_INHERIT_PROVIDER_CPPLUGINS( + MeshReader, + cpPlugins::Interface::Object + ); } // ecapseman diff --git a/lib/cpPlugins/Plugins/RGBImageToHSVChannelsFilter.cxx b/lib/cpPlugins/Plugins/RGBImageToHSVChannelsFilter.cxx index 8d54034..339a818 100644 --- a/lib/cpPlugins/Plugins/RGBImageToHSVChannelsFilter.cxx +++ b/lib/cpPlugins/Plugins/RGBImageToHSVChannelsFilter.cxx @@ -7,17 +7,25 @@ #include // ------------------------------------------------------------------------- -#define cpPlugins_RGBImageToHSVChannelsFilter_Dimension( r, d, o, f ) \ +#define cpPlugins_RGB2HSV_Dimension( r, d, o, f ) \ if( dynamic_cast< itk::ImageBase< d >* >( o ) != NULL ) \ r = this->f< d >( ) // ------------------------------------------------------------------------- -#define cpPlugins_RGBImageToHSVChannelsFilter_RGB( r, p, d, o, f ) \ +#define cpPlugins_RGB2HSV_RGB( r, p, d, o, f ) \ if( \ dynamic_cast< itk::Image< itk::RGBPixel< p >, d >* >( o ) != NULL \ ) \ r = this->f< p, d >( ) + +// ------------------------------------------------------------------------- +std::string cpPlugins::Plugins::RGBImageToHSVChannelsFilter:: +GetClassName( ) const +{ + return( "cpPlugins::Plugins::RGBImageToHSVChannelsFilter" ); +} + // ------------------------------------------------------------------------- cpPlugins::Plugins::RGBImageToHSVChannelsFilter:: RGBImageToHSVChannelsFilter( ) @@ -38,13 +46,6 @@ cpPlugins::Plugins::RGBImageToHSVChannelsFilter:: { } -// ------------------------------------------------------------------------- -std::string cpPlugins::Plugins::RGBImageToHSVChannelsFilter:: -GetClassName( ) const -{ - return( "cpPlugins::Plugins::RGBImageToHSVChannelsFilter" ); -} - // ------------------------------------------------------------------------- std::string cpPlugins::Plugins::RGBImageToHSVChannelsFilter:: _GenerateData( ) @@ -52,10 +53,10 @@ _GenerateData( ) itk::DataObject* o = this->_GetInput( 0 ); std::string r = "cpPlugins::Plugins::RGBImageToHSVChannelsFilter: itk::Image dimension not supported."; - cpPlugins_RGBImageToHSVChannelsFilter_Dimension( r, 1, o, _GD0 ); - else cpPlugins_RGBImageToHSVChannelsFilter_Dimension( r, 2, o, _GD0 ); - else cpPlugins_RGBImageToHSVChannelsFilter_Dimension( r, 3, o, _GD0 ); - else cpPlugins_RGBImageToHSVChannelsFilter_Dimension( r, 4, o, _GD0 ); + cpPlugins_RGB2HSV_Dimension( r, 1, o, _GD0 ); + else cpPlugins_RGB2HSV_Dimension( r, 2, o, _GD0 ); + else cpPlugins_RGB2HSV_Dimension( r, 3, o, _GD0 ); + else cpPlugins_RGB2HSV_Dimension( r, 4, o, _GD0 ); return( r ); } @@ -68,16 +69,16 @@ _GD0( ) dynamic_cast< itk::ImageBase< D >* >( this->_GetInput( 0 ) ); std::string r = "cpPlugins::Plugins::RGBImageToHSVChannelsFilter: itk::Image pixel type not supported"; - cpPlugins_RGBImageToHSVChannelsFilter_RGB( r, char, D, i, _GD1 ); - else cpPlugins_RGBImageToHSVChannelsFilter_RGB( r, short, D, i, _GD1 ); - else cpPlugins_RGBImageToHSVChannelsFilter_RGB( r, int, D, i, _GD1 ); - else cpPlugins_RGBImageToHSVChannelsFilter_RGB( r, long, D, i, _GD1 ); - else cpPlugins_RGBImageToHSVChannelsFilter_RGB( r, unsigned char, D, i, _GD1 ); - else cpPlugins_RGBImageToHSVChannelsFilter_RGB( r, unsigned short, D, i, _GD1 ); - else cpPlugins_RGBImageToHSVChannelsFilter_RGB( r, unsigned int, D, i, _GD1 ); - else cpPlugins_RGBImageToHSVChannelsFilter_RGB( r, unsigned long, D, i, _GD1 ); - else cpPlugins_RGBImageToHSVChannelsFilter_RGB( r, float, D, i, _GD1 ); - else cpPlugins_RGBImageToHSVChannelsFilter_RGB( r, double, D, i, _GD1 ); + cpPlugins_RGB2HSV_RGB( r, char, D, i, _GD1 ); + else cpPlugins_RGB2HSV_RGB( r, short, D, i, _GD1 ); + else cpPlugins_RGB2HSV_RGB( r, int, D, i, _GD1 ); + else cpPlugins_RGB2HSV_RGB( r, long, D, i, _GD1 ); + else cpPlugins_RGB2HSV_RGB( r, unsigned char, D, i, _GD1 ); + else cpPlugins_RGB2HSV_RGB( r, unsigned short, D, i, _GD1 ); + else cpPlugins_RGB2HSV_RGB( r, unsigned int, D, i, _GD1 ); + else cpPlugins_RGB2HSV_RGB( r, unsigned long, D, i, _GD1 ); + else cpPlugins_RGB2HSV_RGB( r, float, D, i, _GD1 ); + else cpPlugins_RGB2HSV_RGB( r, double, D, i, _GD1 ); return( r ); } @@ -93,11 +94,12 @@ _GD1( ) // Filter creation _TFilter* filter = - dynamic_cast< _TFilter* >( this->m_Filter.GetPointer( ) ); + dynamic_cast< _TFilter* >( this->m_RealProcessObject.GetPointer( ) ); if( filter == NULL ) { - this->m_Filter = _TFilter::New( ); - filter = dynamic_cast< _TFilter* >( this->m_Filter.GetPointer( ) ); + this->m_RealProcessObject = _TFilter::New( ); + filter = + dynamic_cast< _TFilter* >( this->m_RealProcessObject.GetPointer( ) ); } // fi filter->SetInput( dynamic_cast< _TImage* >( this->_GetInput( 0 ) ) ); diff --git a/lib/cpPlugins/Plugins/RGBImageToHSVChannelsFilter.h b/lib/cpPlugins/Plugins/RGBImageToHSVChannelsFilter.h index bbe124a..d9fe353 100644 --- a/lib/cpPlugins/Plugins/RGBImageToHSVChannelsFilter.h +++ b/lib/cpPlugins/Plugins/RGBImageToHSVChannelsFilter.h @@ -3,7 +3,6 @@ #include #include -#include namespace cpPlugins { @@ -17,17 +16,26 @@ namespace cpPlugins public: typedef RGBImageToHSVChannelsFilter Self; typedef cpPlugins::Interface::ImageToImageFilter Superclass; + typedef itk::SmartPointer< Self > Pointer; + typedef itk::SmartPointer< const Self > ConstPointer; typedef Superclass::TParameter TParameter; typedef Superclass::TParameters TParameters; public: - RGBImageToHSVChannelsFilter( ); - virtual ~RGBImageToHSVChannelsFilter( ); + itkNewMacro( Self ); + itkTypeMacro( + RGBImageToHSVChannelsFilter, + cpPluginsInterfaceImageToImageFilter + ); + public: virtual std::string GetClassName( ) const; protected: + RGBImageToHSVChannelsFilter( ); + virtual ~RGBImageToHSVChannelsFilter( ); + virtual std::string _GenerateData( ); template< unsigned int D > @@ -36,12 +44,14 @@ namespace cpPlugins template< class P, unsigned int D > std::string _GD1( ); - protected: - itk::ProcessObject::Pointer m_Filter; + private: + // Purposely not implemented + RGBImageToHSVChannelsFilter( const Self& ); + Self& operator=( const Self& ); }; // --------------------------------------------------------------------- - PLUMA_INHERIT_PROVIDER( + PLUMA_INHERIT_PROVIDER_CPPLUGINS( RGBImageToHSVChannelsFilter, cpPlugins::Interface::Object );