From bebef39d45df113f3a706279a395eba44ce9472c Mon Sep 17 00:00:00 2001 From: Leonardo Florez-Valencia Date: Sat, 16 Apr 2016 18:58:04 -0500 Subject: [PATCH] ... --- .../plugins/example_ReadWriteImage.cxx | 7 +- .../example_ReadWriteImageWithWorkspace.cxx | 7 +- lib/cpPipelineEditor/BaseQtMainWindow.cxx | 33 +++- lib/cpPlugins/Image.hxx | 142 +++++++++++------- lib/cpPlugins/ProcessObject.cxx | 80 +++++++--- lib/cpPlugins/ProcessObject.h | 17 ++- lib/cpPlugins/Workspace.cxx | 25 ++- lib/cpPlugins/Workspace.h | 4 +- .../JoinBoundingBoxes.cxx | 3 +- .../JoinBoundingBoxes.h | 2 +- plugins/cpPluginsIO/DataReproducer.cxx | 5 +- plugins/cpPluginsIO/DataReproducer.h | 2 +- plugins/cpPluginsIO/ImageReader.cxx | 113 ++++++-------- plugins/cpPluginsIO/ImageReader.h | 6 +- plugins/cpPluginsIO/ImageWriter.cxx | 60 +++----- plugins/cpPluginsIO/ImageWriter.h | 10 +- plugins/cpPluginsIO/MeshReader.cxx | 27 ++-- plugins/cpPluginsIO/MeshReader.h | 6 +- plugins/cpPluginsIO/MeshWriter.cxx | 14 +- plugins/cpPluginsIO/MeshWriter.h | 2 +- .../cpPluginsImageFilters/AndImageFilter.cxx | 27 ++-- .../cpPluginsImageFilters/AndImageFilter.h | 4 +- .../BinaryContourImageFilter.cxx | 30 ++-- .../BinaryContourImageFilter.h | 6 +- .../BinaryThresholdImageFilter.cxx | 23 +-- .../BinaryThresholdImageFilter.h | 6 +- .../MultiScaleGaussianImageFilter.cxx | 53 ++----- .../MultiScaleGaussianImageFilter.h | 6 +- .../cpPluginsImageFilters/OrImageFilter.cxx | 27 ++-- plugins/cpPluginsImageFilters/OrImageFilter.h | 4 +- .../ResampleImageFilter.cxx | 31 ++-- .../ResampleImageFilter.h | 6 +- .../SignedMaurerDistanceMapImageFilter.cxx | 32 ++-- .../SignedMaurerDistanceMapImageFilter.h | 6 +- .../MarchingCubes.cxx | 7 +- .../cpPluginsImageMeshFilters/MarchingCubes.h | 2 +- .../TriangleMeshToBinaryImageFilter.cxx | 17 +-- .../TriangleMeshToBinaryImageFilter.h | 6 +- .../AppendMeshesFilter.cxx | 6 +- .../cpPluginsMeshFilters/AppendMeshesFilter.h | 2 +- .../NoInteractiveSeedWidget.cxx | 13 +- .../NoInteractiveSeedWidget.h | 4 +- plugins/cpPluginsWidgets/SeedWidget.cxx | 13 +- plugins/cpPluginsWidgets/SeedWidget.h | 4 +- 44 files changed, 447 insertions(+), 453 deletions(-) diff --git a/appli/examples/plugins/example_ReadWriteImage.cxx b/appli/examples/plugins/example_ReadWriteImage.cxx index 3eb89d8..e327074 100644 --- a/appli/examples/plugins/example_ReadWriteImage.cxx +++ b/appli/examples/plugins/example_ReadWriteImage.cxx @@ -78,8 +78,11 @@ int main( int argc, char* argv[] ) writer->SetInput( "Input", reader->GetOutput( "Output" ) ); // Execute filters - std::string err = writer->Update( ); - if( err != "" ) + try + { + writer->Update( ); + } + catch( itk::ExceptionObject& err ) { std::cout << "Error caught: " << err << std::endl; ret = 1; diff --git a/appli/examples/plugins/example_ReadWriteImageWithWorkspace.cxx b/appli/examples/plugins/example_ReadWriteImageWithWorkspace.cxx index 630744a..cba6793 100644 --- a/appli/examples/plugins/example_ReadWriteImageWithWorkspace.cxx +++ b/appli/examples/plugins/example_ReadWriteImageWithWorkspace.cxx @@ -45,8 +45,11 @@ int main( int argc, char* argv[] ) writer_params->SetSaveFileName( "FileName", argv[ argc - 1 ] ); // Execute - std::string err = workspace.Execute( ); - if( err != "" ) + try + { + workspace.Execute( ); + } + catch( itk::ExceptionObject& err ) { std::cout << "Error caught: " << err << std::endl; ret = 1; diff --git a/lib/cpPipelineEditor/BaseQtMainWindow.cxx b/lib/cpPipelineEditor/BaseQtMainWindow.cxx index cf5e41f..e507f19 100644 --- a/lib/cpPipelineEditor/BaseQtMainWindow.cxx +++ b/lib/cpPipelineEditor/BaseQtMainWindow.cxx @@ -319,14 +319,39 @@ void cpPipelineEditor::BaseQtMainWindow:: _ExecFilter( const std::string& filter_name ) { this->_Block( ); - std::string err = this->m_Workspace.Execute( filter_name ); - this->_UnBlock( ); - if( err != "" ) + try + { + this->m_Workspace.Execute( filter_name ); + this->_UnBlock( ); + } + catch( itk::ExceptionObject& err1 ) + { QMessageBox::critical( this, QMessageBox::tr( "Error executing filter" ), - QMessageBox::tr( err.c_str( ) ) + QMessageBox::tr( err1.GetDescription( ) ) ); + this->_UnBlock( ); + } + catch( std::exception& err2 ) + { + QMessageBox::critical( + this, + QMessageBox::tr( "Error executing filter" ), + QMessageBox::tr( err2.what( ) ) + ); + this->_UnBlock( ); + } + catch( ... ) + { + QMessageBox::critical( + this, + QMessageBox::tr( "Error executing filter" ), + QMessageBox::tr( "Unknown error" ) + ); + this->_UnBlock( ); + + } // yrt } // eof - $RCSfile$ diff --git a/lib/cpPlugins/Image.hxx b/lib/cpPlugins/Image.hxx index 4a02cf9..d0f3de4 100644 --- a/lib/cpPlugins/Image.hxx +++ b/lib/cpPlugins/Image.hxx @@ -104,63 +104,91 @@ _ITK_2_VTK_2( itk::LightObject* o ) * Demangle macros * ========================================================================= */ -#define cpPlugin_Image_Demangle_Dim( FUNC, INPUT, D ) \ - this->FUNC( INPUT->GetITK< itk::ImageBase< D > >( ) ) - -#define cpPlugin_Image_Demangle_Pixel_Dim( FUNC, INPUT, PIXEL, D ) \ - this->FUNC( dynamic_cast< itk::Image< PIXEL, D >* >( INPUT ) ) - -#define cpPlugin_Image_Demangle_VectorPixel_Dim( FUNC, INPUT, VECTOR, PIXEL, D ) \ - this->FUNC( dynamic_cast< itk::Image< VECTOR< PIXEL, D >, D >* >( INPUT ) ) - -#define cpPlugin_Image_Demangle_Pixel_AllInts( r, FUNC, INPUT, D ) \ - r = cpPlugin_Image_Demangle_Pixel_Dim( FUNC, INPUT, char, D ); \ - if( r != "" ) r = cpPlugin_Image_Demangle_Pixel_Dim( FUNC, INPUT, short, D ); \ - if( r != "" ) r = cpPlugin_Image_Demangle_Pixel_Dim( FUNC, INPUT, int, D ); \ - if( r != "" ) r = cpPlugin_Image_Demangle_Pixel_Dim( FUNC, INPUT, long, D ); \ - if( r != "" ) r = cpPlugin_Image_Demangle_Pixel_Dim( FUNC, INPUT, unsigned char, D ); \ - if( r != "" ) r = cpPlugin_Image_Demangle_Pixel_Dim( FUNC, INPUT, unsigned short, D ); \ - if( r != "" ) r = cpPlugin_Image_Demangle_Pixel_Dim( FUNC, INPUT, unsigned int, D ); \ - if( r != "" ) r = cpPlugin_Image_Demangle_Pixel_Dim( FUNC, INPUT, unsigned long, D ) - -#define cpPlugin_Image_Demangle_Pixel_AllScalars( r, FUNC, INPUT, D ) \ - r = cpPlugin_Image_Demangle_Pixel_Dim( FUNC, INPUT, char, D ); \ - if( r != "" ) r = cpPlugin_Image_Demangle_Pixel_Dim( FUNC, INPUT, short, D ); \ - if( r != "" ) r = cpPlugin_Image_Demangle_Pixel_Dim( FUNC, INPUT, int, D ); \ - if( r != "" ) r = cpPlugin_Image_Demangle_Pixel_Dim( FUNC, INPUT, long, D ); \ - if( r != "" ) r = cpPlugin_Image_Demangle_Pixel_Dim( FUNC, INPUT, float, D ); \ - if( r != "" ) r = cpPlugin_Image_Demangle_Pixel_Dim( FUNC, INPUT, double, D ); \ - if( r != "" ) r = cpPlugin_Image_Demangle_Pixel_Dim( FUNC, INPUT, unsigned char, D ); \ - if( r != "" ) r = cpPlugin_Image_Demangle_Pixel_Dim( FUNC, INPUT, unsigned short, D ); \ - if( r != "" ) r = cpPlugin_Image_Demangle_Pixel_Dim( FUNC, INPUT, unsigned int, D ); \ - if( r != "" ) r = cpPlugin_Image_Demangle_Pixel_Dim( FUNC, INPUT, unsigned long, D ) - -#define cpPlugin_Image_Demangle_Pixel_AllColor( r, FUNC, INPUT, D ) \ - r = cpPlugin_Image_Demangle_Pixel_Dim( FUNC, INPUT, itk::RGBPixel< char >, D ); \ - if( r != "" ) r = cpPlugin_Image_Demangle_Pixel_Dim( FUNC, INPUT, itk::RGBPixel< short >, D ); \ - if( r != "" ) r = cpPlugin_Image_Demangle_Pixel_Dim( FUNC, INPUT, itk::RGBPixel< int >, D ); \ - if( r != "" ) r = cpPlugin_Image_Demangle_Pixel_Dim( FUNC, INPUT, itk::RGBPixel< long >, D ); \ - if( r != "" ) r = cpPlugin_Image_Demangle_Pixel_Dim( FUNC, INPUT, itk::RGBPixel< float >, D ); \ - if( r != "" ) r = cpPlugin_Image_Demangle_Pixel_Dim( FUNC, INPUT, itk::RGBPixel< double >, D ); \ - if( r != "" ) r = cpPlugin_Image_Demangle_Pixel_Dim( FUNC, INPUT, itk::RGBPixel< unsigned char >, D ); \ - if( r != "" ) r = cpPlugin_Image_Demangle_Pixel_Dim( FUNC, INPUT, itk::RGBPixel< unsigned short >, D ); \ - if( r != "" ) r = cpPlugin_Image_Demangle_Pixel_Dim( FUNC, INPUT, itk::RGBPixel< unsigned int >, D ); \ - if( r != "" ) r = cpPlugin_Image_Demangle_Pixel_Dim( FUNC, INPUT, itk::RGBPixel< unsigned long >, D ); \ - if( r != "" ) r = cpPlugin_Image_Demangle_Pixel_Dim( FUNC, INPUT, itk::RGBAPixel< char >, D ); \ - if( r != "" ) r = cpPlugin_Image_Demangle_Pixel_Dim( FUNC, INPUT, itk::RGBAPixel< short >, D ); \ - if( r != "" ) r = cpPlugin_Image_Demangle_Pixel_Dim( FUNC, INPUT, itk::RGBAPixel< int >, D ); \ - if( r != "" ) r = cpPlugin_Image_Demangle_Pixel_Dim( FUNC, INPUT, itk::RGBAPixel< long >, D ); \ - if( r != "" ) r = cpPlugin_Image_Demangle_Pixel_Dim( FUNC, INPUT, itk::RGBAPixel< float >, D ); \ - if( r != "" ) r = cpPlugin_Image_Demangle_Pixel_Dim( FUNC, INPUT, itk::RGBAPixel< double >, D ); \ - if( r != "" ) r = cpPlugin_Image_Demangle_Pixel_Dim( FUNC, INPUT, itk::RGBAPixel< unsigned char >, D ); \ - if( r != "" ) r = cpPlugin_Image_Demangle_Pixel_Dim( FUNC, INPUT, itk::RGBAPixel< unsigned short >, D ); \ - if( r != "" ) r = cpPlugin_Image_Demangle_Pixel_Dim( FUNC, INPUT, itk::RGBAPixel< unsigned int >, D ); \ - if( r != "" ) r = cpPlugin_Image_Demangle_Pixel_Dim( FUNC, INPUT, itk::RGBAPixel< unsigned long >, D ) - -#define cpPlugin_Image_Demangle_VectorPixel_AllFloats( r, FUNC, INPUT, VECTOR, D ) \ - r = cpPlugin_Image_Demangle_VectorPixel_Dim( FUNC, INPUT, VECTOR, float, D ); \ - if( r != "" ) r = cpPlugin_Image_Demangle_VectorPixel_Dim( FUNC, INPUT, VECTOR, double, D ) - +#define cpPlugins_Image_Demangle_Dim( F, I, D ) \ + if( dynamic_cast< itk::ImageBase< D >* >( I ) != NULL ) \ + this->F( dynamic_cast< itk::ImageBase< D >* >( I ) ) + +#define cpPlugins_Image_Demangle_Pixel_Dim( F, I, P, D ) \ + if( dynamic_cast< itk::Image< P, D >* >( I ) != NULL ) \ + this->F( dynamic_cast< itk::Image< P, D >* >( I ) ) + +#define cpPlugins_Image_Demangle_ColorPixel_Dim( F, I, C, P, D ) \ + if( dynamic_cast< itk::Image< itk::C##Pixel< P >, D >* >( I ) != NULL ) \ + this->F( dynamic_cast< itk::Image< itk::C##Pixel< P >, D >* >( I ) ) + +#define cpPlugins_Image_Demangle_VectorPixel_Dim( F, I, V, P, D ) \ + if( dynamic_cast< itk::Image< V< P, D >, D >* >( I ) != NULL ) \ + this->F( dynamic_cast< itk::Image< V< P, D >, D >* >( I ) ) + +#define cpPlugins_Image_Demangle_Pixel_AllInts( F, I, D ) \ + cpPlugins_Image_Demangle_Pixel_Dim ( F, I, char, D ); \ + else cpPlugins_Image_Demangle_Pixel_Dim( F, I, short, D ); \ + else cpPlugins_Image_Demangle_Pixel_Dim( F, I, int, D ); \ + else cpPlugins_Image_Demangle_Pixel_Dim( F, I, long, D ) + +#define cpPlugins_Image_Demangle_Pixel_AllUInts( F, I, D ) \ + cpPlugins_Image_Demangle_Pixel_Dim ( F, I, unsigned char, D ); \ + else cpPlugins_Image_Demangle_Pixel_Dim( F, I, unsigned short, D ); \ + else cpPlugins_Image_Demangle_Pixel_Dim( F, I, unsigned int, D ); \ + else cpPlugins_Image_Demangle_Pixel_Dim( F, I, unsigned long, D ) + +#define cpPlugins_Image_Demangle_Pixel_AllFloats( F, I, D ) \ + cpPlugins_Image_Demangle_Pixel_Dim ( F, I, float, D ); \ + else cpPlugins_Image_Demangle_Pixel_Dim( F, I, double, D ) + +#define cpPlugins_Image_Demangle_Pixel_AllScalars( F, I, D ) \ + cpPlugins_Image_Demangle_Pixel_AllInts ( F, I, D ); \ + else cpPlugins_Image_Demangle_Pixel_AllUInts( F, I, D ); \ + else cpPlugins_Image_Demangle_Pixel_AllInts ( F, I, D ) + +#define cpPlugins_Image_Demangle_ColorPixel_AllInts( F, I, C, D ) \ + cpPlugins_Image_Demangle_ColorPixel_Dim ( F, I, C, char, D ); \ + else cpPlugins_Image_Demangle_ColorPixel_Dim( F, I, C, short, D ); \ + else cpPlugins_Image_Demangle_ColorPixel_Dim( F, I, C, int, D ); \ + else cpPlugins_Image_Demangle_ColorPixel_Dim( F, I, C, long, D ) + +#define cpPlugins_Image_Demangle_ColorPixel_AllUInts( F, I, C, D ) \ + cpPlugins_Image_Demangle_ColorPixel_Dim ( F, I, C, unsigned char, D ); \ + else cpPlugins_Image_Demangle_ColorPixel_Dim( F, I, C, unsigned short, D ); \ + else cpPlugins_Image_Demangle_ColorPixel_Dim( F, I, C, unsigned int, D ); \ + else cpPlugins_Image_Demangle_ColorPixel_Dim( F, I, C, unsigned long, D ) + +#define cpPlugins_Image_Demangle_ColorPixel_AllFloats( F, I, C, D ) \ + cpPlugins_Image_Demangle_ColorPixel_Dim ( F, I, C, float, D ); \ + else cpPlugins_Image_Demangle_ColorPixel_Dim( F, I, C, double, D ) + +#define cpPlugins_Image_Demangle_ColorPixel_AllScalars( F, I, C, D ) \ + cpPlugins_Image_Demangle_ColorPixel_AllInts ( F, I, C, D ); \ + else cpPlugins_Image_Demangle_ColorPixel_AllUInts( F, I, C, D ); \ + else cpPlugins_Image_Demangle_ColorPixel_AllInts ( F, I, C, D ) + +/* TODO + #define cpPlugins_Image_Demangle_Pixel_AllColor( r, FUNC, INPUT, D ) \ + r = cpPlugins_Image_Demangle_Pixel_Dim( FUNC, INPUT, itk::RGBPixel< char >, D ); \ + if( r != "" ) r = cpPlugins_Image_Demangle_Pixel_Dim( FUNC, INPUT, itk::RGBPixel< short >, D ); \ + if( r != "" ) r = cpPlugins_Image_Demangle_Pixel_Dim( FUNC, INPUT, itk::RGBPixel< int >, D ); \ + if( r != "" ) r = cpPlugins_Image_Demangle_Pixel_Dim( FUNC, INPUT, itk::RGBPixel< long >, D ); \ + if( r != "" ) r = cpPlugins_Image_Demangle_Pixel_Dim( FUNC, INPUT, itk::RGBPixel< float >, D ); \ + if( r != "" ) r = cpPlugins_Image_Demangle_Pixel_Dim( FUNC, INPUT, itk::RGBPixel< double >, D ); \ + if( r != "" ) r = cpPlugins_Image_Demangle_Pixel_Dim( FUNC, INPUT, itk::RGBPixel< unsigned char >, D ); \ + if( r != "" ) r = cpPlugins_Image_Demangle_Pixel_Dim( FUNC, INPUT, itk::RGBPixel< unsigned short >, D ); \ + if( r != "" ) r = cpPlugins_Image_Demangle_Pixel_Dim( FUNC, INPUT, itk::RGBPixel< unsigned int >, D ); \ + if( r != "" ) r = cpPlugins_Image_Demangle_Pixel_Dim( FUNC, INPUT, itk::RGBPixel< unsigned long >, D ); \ + if( r != "" ) r = cpPlugins_Image_Demangle_Pixel_Dim( FUNC, INPUT, itk::RGBAPixel< char >, D ); \ + if( r != "" ) r = cpPlugins_Image_Demangle_Pixel_Dim( FUNC, INPUT, itk::RGBAPixel< short >, D ); \ + if( r != "" ) r = cpPlugins_Image_Demangle_Pixel_Dim( FUNC, INPUT, itk::RGBAPixel< int >, D ); \ + if( r != "" ) r = cpPlugins_Image_Demangle_Pixel_Dim( FUNC, INPUT, itk::RGBAPixel< long >, D ); \ + if( r != "" ) r = cpPlugins_Image_Demangle_Pixel_Dim( FUNC, INPUT, itk::RGBAPixel< float >, D ); \ + if( r != "" ) r = cpPlugins_Image_Demangle_Pixel_Dim( FUNC, INPUT, itk::RGBAPixel< double >, D ); \ + if( r != "" ) r = cpPlugins_Image_Demangle_Pixel_Dim( FUNC, INPUT, itk::RGBAPixel< unsigned char >, D ); \ + if( r != "" ) r = cpPlugins_Image_Demangle_Pixel_Dim( FUNC, INPUT, itk::RGBAPixel< unsigned short >, D ); \ + if( r != "" ) r = cpPlugins_Image_Demangle_Pixel_Dim( FUNC, INPUT, itk::RGBAPixel< unsigned int >, D ); \ + if( r != "" ) r = cpPlugins_Image_Demangle_Pixel_Dim( FUNC, INPUT, itk::RGBAPixel< unsigned long >, D ) + + #define cpPlugins_Image_Demangle_VectorPixel_AllFloats( r, FUNC, INPUT, VECTOR, D ) \ + r = cpPlugins_Image_Demangle_VectorPixel_Dim( FUNC, INPUT, VECTOR, float, D ); \ + if( r != "" ) r = cpPlugins_Image_Demangle_VectorPixel_Dim( FUNC, INPUT, VECTOR, double, D ) +*/ #endif // __CPPLUGINS__IMAGE__HXX__ // eof - $RCSfile$ diff --git a/lib/cpPlugins/ProcessObject.cxx b/lib/cpPlugins/ProcessObject.cxx index aa91064..02beb88 100644 --- a/lib/cpPlugins/ProcessObject.cxx +++ b/lib/cpPlugins/ProcessObject.cxx @@ -1,7 +1,8 @@ #include #include #include - +#include +#include // ------------------------------------------------------------------------- cpPlugins::Parameters* cpPlugins::ProcessObject:: GetParameters( ) @@ -189,6 +190,14 @@ Disconnect( ) this->DisconnectOutputs( ); } +// ------------------------------------------------------------------------- +void cpPlugins::ProcessObject:: +Modified( ) const +{ + this->Superclass::Modified( ); + this->m_LastExecutionSpan = -1; +} + // ------------------------------------------------------------------------- itk::ModifiedTimeType cpPlugins::ProcessObject:: GetMTime( ) const @@ -199,30 +208,28 @@ GetMTime( ) const } // ------------------------------------------------------------------------- -std::string cpPlugins::ProcessObject:: +void cpPlugins::ProcessObject:: Update( ) { - std::string r = ""; - // Force upstream updates auto i = this->m_Inputs.begin( ); bool need_to_update = false; - for( ; i != this->m_Inputs.end( ) && r == ""; ++i ) + for( ; i != this->m_Inputs.end( ); ++i ) { bool iv = i->second.IsValid( ); bool ir = i->second.IsRequired( ); if( !iv && ir ) - r = - "ProcessObject: Required input \"" + - i->first + "@" + this->GetClassName( ) + - "\" is not valid (=NULL)."; - if( iv && r == "" ) + this->_Error( + std::string( "Required input \"" ) + i->first + + std::string( "\" is not valid." ) + ); + if( iv ) { Self* src = dynamic_cast< Self* >( i->second->GetSource( ) ); if( src != NULL ) { need_to_update |= ( this->m_LastExecutionTime < src->GetMTime( ) ); - r = src->Update( ); + src->Update( ); } // fi @@ -231,27 +238,33 @@ Update( ) } // rof // Current update - if( r == "" ) + if( this->m_LastExecutionTime < this->GetMTime( ) || need_to_update ) { - if( this->m_LastExecutionTime < this->GetMTime( ) || need_to_update ) + if( this->m_PrintExecution && this->m_PrintExecutionStream != NULL ) { - std::cout + *( this->m_PrintExecutionStream ) << "cpPlugins: Updating \"" - << this->GetClassName( ) << ":" << this->GetClassCategory( ) + << this->GetClassCategory( ) << ":" << this->GetClassName( ) << "\"... "; - std::cout.flush( ); - this->m_LastExecutionSpan = cpPlugins_CHRONO; - r = this->_GenerateData( ); - this->m_LastExecutionSpan = cpPlugins_CHRONO - this->m_LastExecutionSpan; - this->m_LastExecutionTime = this->GetMTime( ); - std::cout << "done in " << ( double( this->m_LastExecutionSpan ) / double( 1000 ) ) << "s!" << std::endl; + this->m_PrintExecutionStream->flush( ); } // fi - } // fi + this->m_LastExecutionSpan = cpPlugins_CHRONO; + this->_GenerateData( ); + this->m_LastExecutionSpan = cpPlugins_CHRONO - this->m_LastExecutionSpan; + this->m_LastExecutionTime = this->GetMTime( ); + + if( this->m_PrintExecution && this->m_PrintExecutionStream != NULL ) + { + *( this->m_PrintExecutionStream ) + << "done in " + << this->m_LastExecutionSpan + << " ms." << std::endl; - // Return error description, if any - return( r ); + } // fi + + } // fi } // ------------------------------------------------------------------------- @@ -290,7 +303,10 @@ SetInteractionObjects( const std::vector< void* >& objs ) cpPlugins::ProcessObject:: ProcessObject( ) : Superclass( ), - m_LastExecutionTime( 0 ) + m_LastExecutionTime( 0 ), + m_LastExecutionSpan( -1 ), + m_PrintExecution( false ), + m_PrintExecutionStream( &( std::cout ) ) { } @@ -313,4 +329,18 @@ _AddInput( const std::string& name, bool required ) } // fi } +// ------------------------------------------------------------------------- +void cpPlugins::ProcessObject:: +_Error( const std::string& error ) +{ + if( error != "" ) + { + itkExceptionMacro( + "Error: \"" << this->GetClassCategory( ) << "::" << + this->GetClassName( ) << "\": " << error + ); + + } // fi +} + // eof - $RCSfile$ diff --git a/lib/cpPlugins/ProcessObject.h b/lib/cpPlugins/ProcessObject.h index b0a6a71..908fd92 100644 --- a/lib/cpPlugins/ProcessObject.h +++ b/lib/cpPlugins/ProcessObject.h @@ -24,6 +24,12 @@ namespace cpPlugins itkTypeMacro( ProcessObject, Object ); cpPlugins_Id_Macro( ProcessObject, Object ); + itkBooleanMacro( PrintExecution ); + itkGetConstMacro( LastExecutionSpan, long ); + itkGetConstMacro( PrintExecution, bool ); + itkSetMacro( PrintExecution, bool ); + itkSetObjectMacro( PrintExecutionStream, std::ofstream ); + public: Parameters* GetParameters( ); const Parameters* GetParameters( ) const; @@ -52,8 +58,9 @@ namespace cpPlugins void Disconnect( ); // Pipeline execution + virtual void Modified( ) const ITK_OVERRIDE; virtual itk::ModifiedTimeType GetMTime( ) const ITK_OVERRIDE; - virtual std::string Update( ); + virtual void Update( ); // Qt dialog creation virtual ParametersQtDialog* CreateQtDialog( ); @@ -65,6 +72,7 @@ namespace cpPlugins virtual ~ProcessObject( ); void _AddInput( const std::string& name, bool required = true ); + void _Error( const std::string& error ); template< class O > inline void _AddOutput( const std::string& name ); @@ -74,7 +82,7 @@ namespace cpPlugins template< class F > inline F* _CreateVTK( ); - virtual std::string _GenerateData( ) = 0; + virtual void _GenerateData( ) = 0; private: // Purposely not implemented @@ -90,7 +98,10 @@ namespace cpPlugins _TOutputs m_Outputs; itk::ModifiedTimeType m_LastExecutionTime; - long m_LastExecutionSpan; + mutable long m_LastExecutionSpan; + + bool m_PrintExecution; + std::ostream* m_PrintExecutionStream; }; } // ecapseman diff --git a/lib/cpPlugins/Workspace.cxx b/lib/cpPlugins/Workspace.cxx index 7ba11d1..a63b749 100644 --- a/lib/cpPlugins/Workspace.cxx +++ b/lib/cpPlugins/Workspace.cxx @@ -394,38 +394,33 @@ GetExposedOutput( const std::string& name ) const } // ------------------------------------------------------------------------- -std::string cpPlugins::Workspace:: +void cpPlugins::Workspace:: Execute( ) { // Find sinks std::set< std::string > sinks = this->m_Graph->GetSinks( ); // Update sinks - std::string err = ""; for( auto sIt = sinks.begin( ); sIt != sinks.end( ); ++sIt ) - { - std::string lerr = this->Execute( *sIt ); - if( lerr != "" ) - err += lerr + std::string( "\n" ); - - } // rof - return( err ); + this->Execute( *sIt ); } // ------------------------------------------------------------------------- -std::string cpPlugins::Workspace:: +void cpPlugins::Workspace:: Execute( const std::string& name ) { // Get filter ProcessObject* f = this->GetFilter( name ); if( f == NULL ) - return( - std::string( "cpPlugins::Workspace: Vertex \"" ) + - name + std::string( "\" is not a filter." ) + { + itkGenericExceptionMacro( + "cpPlugins::Workspace: Vertex \"" << name << "\" is not a filter." ); - // Execute and return - return( f->Update( ) ); + } // fi + + // Execute + f->Update( ); } // eof - $RCSfile$ diff --git a/lib/cpPlugins/Workspace.h b/lib/cpPlugins/Workspace.h index d99831b..e779b07 100644 --- a/lib/cpPlugins/Workspace.h +++ b/lib/cpPlugins/Workspace.h @@ -130,8 +130,8 @@ namespace cpPlugins const OutputPort& GetExposedOutput( const std::string& name ) const; // Pipeline execution - std::string Execute( ); - std::string Execute( const std::string& name ); + void Execute( ); + void Execute( const std::string& name ); protected: // Plugins interface diff --git a/plugins/cpPluginsGenericFilters/JoinBoundingBoxes.cxx b/plugins/cpPluginsGenericFilters/JoinBoundingBoxes.cxx index 911040d..3fcd009 100644 --- a/plugins/cpPluginsGenericFilters/JoinBoundingBoxes.cxx +++ b/plugins/cpPluginsGenericFilters/JoinBoundingBoxes.cxx @@ -23,7 +23,7 @@ cpPluginsGenericFilters::JoinBoundingBoxes:: } // ------------------------------------------------------------------------- -std::string cpPluginsGenericFilters::JoinBoundingBoxes:: +void cpPluginsGenericFilters::JoinBoundingBoxes:: _GenerateData( ) { typedef cpPlugins::DataObject _TDO; @@ -50,7 +50,6 @@ _GenerateData( ) } // fi } // rof - return( "" ); } // eof - $RCSfile$ diff --git a/plugins/cpPluginsGenericFilters/JoinBoundingBoxes.h b/plugins/cpPluginsGenericFilters/JoinBoundingBoxes.h index 3df5da7..f3ea192 100644 --- a/plugins/cpPluginsGenericFilters/JoinBoundingBoxes.h +++ b/plugins/cpPluginsGenericFilters/JoinBoundingBoxes.h @@ -26,7 +26,7 @@ namespace cpPluginsGenericFilters JoinBoundingBoxes( ); virtual ~JoinBoundingBoxes( ); - virtual std::string _GenerateData( ) ITK_OVERRIDE; + virtual void _GenerateData( ) ITK_OVERRIDE; private: // Purposely not implemented diff --git a/plugins/cpPluginsIO/DataReproducer.cxx b/plugins/cpPluginsIO/DataReproducer.cxx index 27f9ea5..538ad1b 100644 --- a/plugins/cpPluginsIO/DataReproducer.cxx +++ b/plugins/cpPluginsIO/DataReproducer.cxx @@ -17,16 +17,15 @@ cpPluginsIO::DataReproducer:: } // ------------------------------------------------------------------------- -std::string cpPluginsIO::DataReproducer:: +void cpPluginsIO::DataReproducer:: _GenerateData( ) { auto i = this->m_Inputs.find( "Input" ); auto o = this->m_Outputs.find( "Output" ); if( i == this->m_Inputs.end( ) || o == this->m_Outputs.end( ) ) - return( "IO::DataReproducer: No input/output ports." ); + this->_Error( "No input/output ports." ); o->second->SetITK( i->second->GetITK< itk::LightObject >( ) ); o->second->SetVTK( i->second->GetVTK< vtkObjectBase >( ) ); - return( "" ); } // eof - $RCSfile$ diff --git a/plugins/cpPluginsIO/DataReproducer.h b/plugins/cpPluginsIO/DataReproducer.h index c1b0028..475501e 100644 --- a/plugins/cpPluginsIO/DataReproducer.h +++ b/plugins/cpPluginsIO/DataReproducer.h @@ -26,7 +26,7 @@ namespace cpPluginsIO DataReproducer( ); virtual ~DataReproducer( ); - virtual std::string _GenerateData( ) ITK_OVERRIDE; + virtual void _GenerateData( ) ITK_OVERRIDE; private: // Purposely not implemented diff --git a/plugins/cpPluginsIO/ImageReader.cxx b/plugins/cpPluginsIO/ImageReader.cxx index e9f3e59..e10d383 100644 --- a/plugins/cpPluginsIO/ImageReader.cxx +++ b/plugins/cpPluginsIO/ImageReader.cxx @@ -24,12 +24,11 @@ cpPluginsIO::ImageReader:: } // ------------------------------------------------------------------------- -std::string cpPluginsIO::ImageReader:: +void cpPluginsIO::ImageReader:: _GenerateData( ) { // Get filenames auto fnames = this->m_Parameters.GetOpenFileNameList( "FileNames" ); - std::string r = ""; if( fnames.size( ) >= 1 ) { // Guess image properties @@ -47,30 +46,30 @@ _GenerateData( ) switch( io->GetNumberOfDimensions( ) ) { // TODO: case 1: r = this->_GD0< 1 >( io ); break; - case 2: r = this->_GD0< 2 >( io ); break; - case 3: r = this->_GD0< 3 >( io ); break; + case 2: this->_GD0< 2 >( io ); break; + case 3: this->_GD0< 3 >( io ); break; // TODO: case 4: r = this->_GD0< 4 >( io ); break; default: - r = "IO::ImageReader: Image dimension not supported."; + this->_Error( "Image dimension not supported." ); break; } // hctiws } // fi } else - r = - "IO::ImageReader: Could not CreateImageIO for \"" + + this->_Error( + std::string( "Could not create an ImageIO for \"" ) + fnames[ 0 ] + - "\""; + std::string( "\"" ) + ); } else - r = "IO::ImageReader: No image(s) given"; - return( r ); + this->_Error( "No image(s) given" ); } // ------------------------------------------------------------------------- template< unsigned int _Dim > -std::string cpPluginsIO::ImageReader:: +void cpPluginsIO::ImageReader:: _GD0( itk::ImageIOBase* io ) { typedef unsigned char uchar; @@ -81,73 +80,64 @@ _GD0( itk::ImageIOBase* io ) itk::ImageIOBase::IOComponentType ct = io->GetComponentType( ); itk::ImageIOBase::IOPixelType pt = io->GetPixelType( ); - std::string r = ""; if( pt == itk::ImageIOBase::SCALAR ) { switch( ct ) { - case itk::ImageIOBase::CHAR : r = this->_GD1< char, _Dim >( io ); break; - case itk::ImageIOBase::SHORT : r = this->_GD1< short, _Dim >( io ); break; - case itk::ImageIOBase::INT : r = this->_GD1< int, _Dim >( io ); break; - case itk::ImageIOBase::LONG : r = this->_GD1< long, _Dim >( io ); break; - case itk::ImageIOBase::FLOAT : r = this->_GD1< float, _Dim >( io ); break; - case itk::ImageIOBase::DOUBLE : r = this->_GD1< double, _Dim >( io ); break; - case itk::ImageIOBase::UCHAR : r = this->_GD1< uchar, _Dim >( io ); break; - case itk::ImageIOBase::USHORT : r = this->_GD1< ushort, _Dim >( io ); break; - case itk::ImageIOBase::UINT : r = this->_GD1< uint, _Dim >( io ); break; - case itk::ImageIOBase::ULONG : r = this->_GD1< ulong, _Dim >( io ); break; - default: - r = "IO::ImageReader: Scalar pixel type not supported."; - break; + case itk::ImageIOBase::CHAR : this->_GD1< char, _Dim >( io ); break; + case itk::ImageIOBase::SHORT : this->_GD1< short, _Dim >( io ); break; + case itk::ImageIOBase::INT : this->_GD1< int, _Dim >( io ); break; + case itk::ImageIOBase::LONG : this->_GD1< long, _Dim >( io ); break; + case itk::ImageIOBase::FLOAT : this->_GD1< float, _Dim >( io ); break; + case itk::ImageIOBase::DOUBLE : this->_GD1< double, _Dim >( io ); break; + case itk::ImageIOBase::UCHAR : this->_GD1< uchar, _Dim >( io ); break; + case itk::ImageIOBase::USHORT : this->_GD1< ushort, _Dim >( io ); break; + case itk::ImageIOBase::UINT : this->_GD1< uint, _Dim >( io ); break; + case itk::ImageIOBase::ULONG : this->_GD1< ulong, _Dim >( io ); break; + default: this->_Error( "Scalar pixel type not supported." ); break; } // hctiws } else if( pt == itk::ImageIOBase::RGB ) { switch( ct ) { - case itk::ImageIOBase::CHAR : r = this->_GD1< itk::RGBPixel< char >, _Dim >( io ); break; - case itk::ImageIOBase::SHORT : r = this->_GD1< itk::RGBPixel< short >, _Dim >( io ); break; - case itk::ImageIOBase::INT : r = this->_GD1< itk::RGBPixel< int >, _Dim >( io ); break; - case itk::ImageIOBase::LONG : r = this->_GD1< itk::RGBPixel< long >, _Dim >( io ); break; - case itk::ImageIOBase::FLOAT : r = this->_GD1< itk::RGBPixel< float >, _Dim >( io ); break; - case itk::ImageIOBase::DOUBLE : r = this->_GD1< itk::RGBPixel< double >, _Dim >( io ); break; - case itk::ImageIOBase::UCHAR : r = this->_GD1< itk::RGBPixel< uchar >, _Dim >( io ); break; - case itk::ImageIOBase::USHORT : r = this->_GD1< itk::RGBPixel< ushort >, _Dim >( io ); break; - case itk::ImageIOBase::UINT : r = this->_GD1< itk::RGBPixel< uint >, _Dim >( io ); break; - case itk::ImageIOBase::ULONG : r = this->_GD1< itk::RGBPixel< ulong >, _Dim >( io ); break; - default: - r = "IO::ImageReader: RGB pixel type not supported."; - break; + case itk::ImageIOBase::CHAR : this->_GD1< itk::RGBPixel< char >, _Dim >( io ); break; + case itk::ImageIOBase::SHORT : this->_GD1< itk::RGBPixel< short >, _Dim >( io ); break; + case itk::ImageIOBase::INT : this->_GD1< itk::RGBPixel< int >, _Dim >( io ); break; + case itk::ImageIOBase::LONG : this->_GD1< itk::RGBPixel< long >, _Dim >( io ); break; + case itk::ImageIOBase::FLOAT : this->_GD1< itk::RGBPixel< float >, _Dim >( io ); break; + case itk::ImageIOBase::DOUBLE : this->_GD1< itk::RGBPixel< double >, _Dim >( io ); break; + case itk::ImageIOBase::UCHAR : this->_GD1< itk::RGBPixel< uchar >, _Dim >( io ); break; + case itk::ImageIOBase::USHORT : this->_GD1< itk::RGBPixel< ushort >, _Dim >( io ); break; + case itk::ImageIOBase::UINT : this->_GD1< itk::RGBPixel< uint >, _Dim >( io ); break; + case itk::ImageIOBase::ULONG : this->_GD1< itk::RGBPixel< ulong >, _Dim >( io ); break; + default: this->_Error( "RGB pixel type not supported." ); break; } // hctiws } else if( pt == itk::ImageIOBase::RGBA ) { switch( ct ) { - case itk::ImageIOBase::CHAR : r = this->_GD1< itk::RGBAPixel< char >, _Dim >( io ); break; - case itk::ImageIOBase::SHORT : r = this->_GD1< itk::RGBAPixel< short >, _Dim >( io ); break; - case itk::ImageIOBase::INT : r = this->_GD1< itk::RGBAPixel< int >, _Dim >( io ); break; - case itk::ImageIOBase::LONG : r = this->_GD1< itk::RGBAPixel< long >, _Dim >( io ); break; - case itk::ImageIOBase::FLOAT : r = this->_GD1< itk::RGBAPixel< float >, _Dim >( io ); break; - case itk::ImageIOBase::DOUBLE : r = this->_GD1< itk::RGBAPixel< double >, _Dim >( io ); break; - case itk::ImageIOBase::UCHAR : r = this->_GD1< itk::RGBAPixel< uchar >, _Dim >( io ); break; - case itk::ImageIOBase::USHORT : r = this->_GD1< itk::RGBAPixel< ushort >, _Dim >( io ); break; - case itk::ImageIOBase::UINT : r = this->_GD1< itk::RGBAPixel< uint >, _Dim >( io ); break; - case itk::ImageIOBase::ULONG : r = this->_GD1< itk::RGBAPixel< ulong >, _Dim >( io ); break; - default: - r = "IO::ImageReader: RGBA pixel type not supported."; - break; + case itk::ImageIOBase::CHAR : this->_GD1< itk::RGBAPixel< char >, _Dim >( io ); break; + case itk::ImageIOBase::SHORT : this->_GD1< itk::RGBAPixel< short >, _Dim >( io ); break; + case itk::ImageIOBase::INT : this->_GD1< itk::RGBAPixel< int >, _Dim >( io ); break; + case itk::ImageIOBase::LONG : this->_GD1< itk::RGBAPixel< long >, _Dim >( io ); break; + case itk::ImageIOBase::FLOAT : this->_GD1< itk::RGBAPixel< float >, _Dim >( io ); break; + case itk::ImageIOBase::DOUBLE : this->_GD1< itk::RGBAPixel< double >, _Dim >( io ); break; + case itk::ImageIOBase::UCHAR : this->_GD1< itk::RGBAPixel< uchar >, _Dim >( io ); break; + case itk::ImageIOBase::USHORT : this->_GD1< itk::RGBAPixel< ushort >, _Dim >( io ); break; + case itk::ImageIOBase::UINT : this->_GD1< itk::RGBAPixel< uint >, _Dim >( io ); break; + case itk::ImageIOBase::ULONG : this->_GD1< itk::RGBAPixel< ulong >, _Dim >( io ); break; + default: this->_Error( "RGBA pixel type not supported." ); break; } // hctiws } else if( pt == itk::ImageIOBase::COMPLEX ) { switch( ct ) { - case itk::ImageIOBase::FLOAT : r = this->_GD1< std::complex< float >, _Dim >( io ); break; - case itk::ImageIOBase::DOUBLE : r = this->_GD1< std::complex< double >, _Dim >( io ); break; - default: - r = "IO::ImageReader: complex pixel type not supported."; - break; + case itk::ImageIOBase::FLOAT : this->_GD1< std::complex< float >, _Dim >( io ); break; + case itk::ImageIOBase::DOUBLE : this->_GD1< std::complex< double >, _Dim >( io ); break; + default: this->_Error( "Complex pixel type not supported." ); break; } // hctiws } /* TODO @@ -177,19 +167,17 @@ _GD0( itk::ImageIOBase* io ) } */ else - r = "IO::ImageReader: Image pixel type not yet supported."; - return( r ); + this->_Error( "Image pixel type not yet supported." ); } // ------------------------------------------------------------------------- template< class _TPixel, unsigned int _Dim > -std::string cpPluginsIO::ImageReader:: +void cpPluginsIO::ImageReader:: _GD1( itk::ImageIOBase* io ) { typedef itk::Image< _TPixel, _Dim > _TImage; // Get filenames - std::string r = ""; auto fnames = this->m_Parameters.GetOpenFileNameList( "FileNames" ); if( fnames.size( ) == 1 ) { @@ -203,7 +191,7 @@ _GD1( itk::ImageIOBase* io ) } catch( itk::ExceptionObject& err ) { - r = "IO::ImageReader: " + std::string( err.GetDescription( ) ); + this->_Error( err.GetDescription( ) ); } } else // if( fnames.size( ) > 1 ) @@ -219,11 +207,10 @@ _GD1( itk::ImageIOBase* io ) } catch( itk::ExceptionObject& err ) { - r = "IO::ImageReader: " + std::string( err.GetDescription( ) ); + this->_Error( err.GetDescription( ) ); } } // fi - return( r ); } // eof - $RCSfile$ diff --git a/plugins/cpPluginsIO/ImageReader.h b/plugins/cpPluginsIO/ImageReader.h index 7b1efe6..0e239e1 100644 --- a/plugins/cpPluginsIO/ImageReader.h +++ b/plugins/cpPluginsIO/ImageReader.h @@ -31,13 +31,13 @@ namespace cpPluginsIO ImageReader( ); virtual ~ImageReader( ); - virtual std::string _GenerateData( ) ITK_OVERRIDE; + virtual void _GenerateData( ) ITK_OVERRIDE; template< unsigned int _Dim > - inline std::string _GD0( itk::ImageIOBase* io ); + inline void _GD0( itk::ImageIOBase* io ); template< class _TPixel, unsigned int _Dim > - inline std::string _GD1( itk::ImageIOBase* io ); + inline void _GD1( itk::ImageIOBase* io ); private: // Purposely not implemented diff --git a/plugins/cpPluginsIO/ImageWriter.cxx b/plugins/cpPluginsIO/ImageWriter.cxx index dfbd097..1855f2e 100644 --- a/plugins/cpPluginsIO/ImageWriter.cxx +++ b/plugins/cpPluginsIO/ImageWriter.cxx @@ -23,54 +23,44 @@ cpPluginsIO::ImageWriter:: } // ------------------------------------------------------------------------- -std::string cpPluginsIO::ImageWriter:: +void cpPluginsIO::ImageWriter:: _GenerateData( ) { - auto input = this->GetInputData( "Input" ); - try - { - std::string r = cpPlugin_Image_Demangle_Dim( _GD0, input, 3 ); - if( r != "" ) r = cpPlugin_Image_Demangle_Dim( _GD0, input, 2 ); - /* TODO - if( r != "" ) r = cpPlugin_Image_Demangle_Dim( _GD0, input, 4 ); - if( r != "" ) r = cpPlugin_Image_Demangle_Dim( _GD0, input, 1 ); - */ - return( r ); - } - catch( itk::ExceptionObject& err ) - { - return( "IO::ImageWriter: " + std::string( err.GetDescription( ) ) ); - } + auto image = this->GetInputData( "Input" )->GetITK< itk::DataObject >( ); + cpPlugins_Image_Demangle_Dim ( _GD0, image, 2 ); + else cpPlugins_Image_Demangle_Dim( _GD0, image, 3 ); + else this->_Error( "No valid input image dimension" ); } // ------------------------------------------------------------------------- -template< class _TInput > -std::string cpPluginsIO::ImageWriter:: -_GD0( _TInput* image ) +template< class _TImage > +void cpPluginsIO::ImageWriter:: +_GD0( _TImage* image ) { - static const unsigned int D = _TInput::ImageDimension; - if( image == NULL ) - return( "IO::ImageWriter: Invalid image dimension." ); - - std::string cpPlugin_Image_Demangle_Pixel_AllScalars( r, _GD1, image, D ); - if( r != "" ) cpPlugin_Image_Demangle_Pixel_AllColor( r, _GD1, image, D ); - return( r ); + static const unsigned int D = _TImage::ImageDimension; + cpPlugins_Image_Demangle_Pixel_AllScalars ( _GD1, image, D ); + else cpPlugins_Image_Demangle_ColorPixel_AllScalars( _GD1, image, RGB, D ); + else cpPlugins_Image_Demangle_ColorPixel_AllScalars( _GD1, image, RGBA, D ); } // ------------------------------------------------------------------------- -template< class _TInput > -std::string cpPluginsIO::ImageWriter:: -_GD1( _TInput* image ) +template< class _TImage > +void cpPluginsIO::ImageWriter:: +_GD1( _TImage* image ) { - typedef itk::ImageFileWriter< _TInput > _TFilter; - - if( image == NULL ) - return( "IO::ImageWriter: Invalid pixel type." ); + typedef itk::ImageFileWriter< _TImage > _TFilter; auto f = this->_CreateITK< _TFilter >( ); f->SetFileName( this->m_Parameters.GetSaveFileName( "FileName" ) ); f->SetInput( image ); - f->Update( ); - return( "" ); + try + { + f->Update( ); + } + catch( itk::ExceptionObject& err ) + { + this->_Error( err.GetDescription( ) ); + + } // yrt } // eof - $RCSfile$ diff --git a/plugins/cpPluginsIO/ImageWriter.h b/plugins/cpPluginsIO/ImageWriter.h index 0873207..ac9e3ad 100644 --- a/plugins/cpPluginsIO/ImageWriter.h +++ b/plugins/cpPluginsIO/ImageWriter.h @@ -26,13 +26,13 @@ namespace cpPluginsIO ImageWriter( ); virtual ~ImageWriter( ); - virtual std::string _GenerateData( ) ITK_OVERRIDE; + virtual void _GenerateData( ) ITK_OVERRIDE; - template< class _TInput > - inline std::string _GD0( _TInput* image ); + template< class _TImage > + inline void _GD0( _TImage* image ); - template< class _TInput > - inline std::string _GD1( _TInput* image ); + template< class _TImage > + inline void _GD1( _TImage* image ); private: // Purposely not implemented diff --git a/plugins/cpPluginsIO/MeshReader.cxx b/plugins/cpPluginsIO/MeshReader.cxx index 49b76a2..eead3da 100644 --- a/plugins/cpPluginsIO/MeshReader.cxx +++ b/plugins/cpPluginsIO/MeshReader.cxx @@ -37,29 +37,29 @@ cpPluginsIO::MeshReader:: } // ------------------------------------------------------------------------- -std::string cpPluginsIO::MeshReader:: +void cpPluginsIO::MeshReader:: _GenerateData( ) { - auto dim = this->m_Parameters.GetUint( "Dimension" ); - if ( dim == 2 ) return( this->_GD0< 2 >( ) ); - else if( dim == 3 ) return( this->_GD0< 3 >( ) ); - else return( "MeshReader: Mesh dimension not supported." ); + auto d = this->m_Parameters.GetUint( "Dimension" ); + if ( d == 2 ) this->_GD0< 2 >( ); + else if( d == 3 ) this->_GD0< 3 >( ); + else this->_Error( "Mesh dimension not supported." ); } // ------------------------------------------------------------------------- template< unsigned int _Dim > -std::string cpPluginsIO::MeshReader:: +void cpPluginsIO::MeshReader:: _GD0( ) { - auto st = this->m_Parameters.GetSelectedChoice( "ScalarType" ); - if ( st == "float" ) return( this->_GD1< float, _Dim >( ) ); - else if( st == "double" ) return( this->_GD1< double, _Dim >( ) ); - else return( "MeshReader: Mesh type not supported." ); + auto s = this->m_Parameters.GetSelectedChoice( "ScalarType" ); + if ( s == "float" ) this->_GD1< float, _Dim >( ); + else if( s == "double" ) this->_GD1< double, _Dim >( ); + else this->_Error( "Mesh type not supported." ); } // ------------------------------------------------------------------------- template< class _TScalar, unsigned int _Dim > -std::string cpPluginsIO::MeshReader:: +void cpPluginsIO::MeshReader:: _GD1( ) { auto fname = this->m_Parameters.GetOpenFileName( "FileName" ); @@ -79,7 +79,6 @@ _GD1( ) stlr->Update( ); this->GetOutputData( "Output" )->SetVTK( stlr->GetOutput( ) ); - return( "" ); } else if( ext == "obj" ) { @@ -88,7 +87,6 @@ _GD1( ) objr->Update( ); this->GetOutputData( "Output" )->SetVTK( objr->GetOutput( ) ); - return( "" ); } else if( ext == "vtk" ) { @@ -97,10 +95,9 @@ _GD1( ) pdr->Update( ); this->GetOutputData( "Output" )->SetVTK( pdr->GetOutput( ) ); - return( "" ); } else - return( "MeshReader: Input file format not recognized." ); + this->_Error( "Input file format not recognized." ); } // eof - $RCSfile$ diff --git a/plugins/cpPluginsIO/MeshReader.h b/plugins/cpPluginsIO/MeshReader.h index c32ac9e..f04fcf6 100644 --- a/plugins/cpPluginsIO/MeshReader.h +++ b/plugins/cpPluginsIO/MeshReader.h @@ -26,13 +26,13 @@ namespace cpPluginsIO MeshReader( ); virtual ~MeshReader( ); - virtual std::string _GenerateData( ) ITK_OVERRIDE; + virtual void _GenerateData( ) ITK_OVERRIDE; template< unsigned int _Dim > - inline std::string _GD0( ); + inline void _GD0( ); template< class _TScalar, unsigned int _Dim > - inline std::string _GD1( ); + inline void _GD1( ); private: // Purposely not implemented diff --git a/plugins/cpPluginsIO/MeshWriter.cxx b/plugins/cpPluginsIO/MeshWriter.cxx index ad5501a..699d382 100644 --- a/plugins/cpPluginsIO/MeshWriter.cxx +++ b/plugins/cpPluginsIO/MeshWriter.cxx @@ -27,12 +27,12 @@ cpPluginsIO::MeshWriter:: } // ------------------------------------------------------------------------- -std::string cpPluginsIO::MeshWriter:: +void cpPluginsIO::MeshWriter:: _GenerateData( ) { auto mesh = this->GetInputData( "Input" )->GetVTK< vtkPolyData >( ); if( mesh == NULL ) - return( "MeshWriter: No suitable input." ); + this->_Error( "No suitable input." ); // Get file extension auto fname = this->m_Parameters.GetSaveFileName( "FileName" ); @@ -50,9 +50,7 @@ _GenerateData( ) stlw->SetFileName( fname.c_str( ) ); stlw->Update( ); if( stlw->GetErrorCode( ) != 0 ) - return( "MeshWriter: someting wrong happened." ); - else - return( "" ); + this->_Error( "Someting wrong happened." ); } else if( ext == "vtk" ) { @@ -61,12 +59,10 @@ _GenerateData( ) pdw->SetFileName( fname.c_str( ) ); pdw->Update( ); if( pdw->GetErrorCode( ) != 0 ) - return( "MeshWriter: someting wrong happened." ); - else - return( "" ); + this->_Error( "Someting wrong happened." ); } else - return( "MeshWriter: Input file format not recognized." ); + this->_Error( "Input file format not recognized." ); } // eof - $RCSfile$ diff --git a/plugins/cpPluginsIO/MeshWriter.h b/plugins/cpPluginsIO/MeshWriter.h index f4c85bc..3957929 100644 --- a/plugins/cpPluginsIO/MeshWriter.h +++ b/plugins/cpPluginsIO/MeshWriter.h @@ -26,7 +26,7 @@ namespace cpPluginsIO MeshWriter( ); virtual ~MeshWriter( ); - virtual std::string _GenerateData( ) ITK_OVERRIDE; + virtual void _GenerateData( ) ITK_OVERRIDE; private: // Purposely not implemented diff --git a/plugins/cpPluginsImageFilters/AndImageFilter.cxx b/plugins/cpPluginsImageFilters/AndImageFilter.cxx index e805798..ecb6a37 100644 --- a/plugins/cpPluginsImageFilters/AndImageFilter.cxx +++ b/plugins/cpPluginsImageFilters/AndImageFilter.cxx @@ -19,20 +19,24 @@ cpPluginsImageFilters::AndImageFilter:: } // ------------------------------------------------------------------------- -std::string cpPluginsImageFilters::AndImageFilter:: +void cpPluginsImageFilters::AndImageFilter:: _GenerateData( ) { auto image = this->GetInputData( "Input0" )->GetITK< itk::DataObject >( ); - std::string cpPlugin_Image_Demangle_Pixel_AllInts( r, _GD0, image, 2 ); - if( r != "" ) cpPlugin_Image_Demangle_Pixel_AllInts( r, _GD0, image, 3 ); - if( r != "" ) cpPlugin_Image_Demangle_Pixel_AllInts( r, _GD0, image, 1 ); - if( r != "" ) cpPlugin_Image_Demangle_Pixel_AllInts( r, _GD0, image, 4 ); - return( r ); + cpPlugins_Image_Demangle_Pixel_AllInts ( _GD0, image, 1 ); + else cpPlugins_Image_Demangle_Pixel_AllInts ( _GD0, image, 2 ); + else cpPlugins_Image_Demangle_Pixel_AllInts ( _GD0, image, 3 ); + else cpPlugins_Image_Demangle_Pixel_AllInts ( _GD0, image, 4 ); + else cpPlugins_Image_Demangle_Pixel_AllUInts( _GD0, image, 1 ); + else cpPlugins_Image_Demangle_Pixel_AllUInts( _GD0, image, 2 ); + else cpPlugins_Image_Demangle_Pixel_AllUInts( _GD0, image, 3 ); + else cpPlugins_Image_Demangle_Pixel_AllUInts( _GD0, image, 4 ); + else this->_Error( "No valid input image." ); } // ------------------------------------------------------------------------- template< class _TImage > -std::string cpPluginsImageFilters::AndImageFilter:: +void cpPluginsImageFilters::AndImageFilter:: _GD0( _TImage* image0 ) { typedef itk::AndImageFilter< _TImage, _TImage > _TFilter; @@ -49,17 +53,12 @@ _GD0( _TImage* image0 ) // Connect output this->GetOutputData( "Output" )->SetITK( filter->GetOutput( ) ); - return( "" ); } else - return( - "ImageFilters::AndImageFilter: No valid second input image." - ); + this->_Error( "No valid second input image." ); } else - return( - "ImageFilters::AndImageFilter: No valid first input image." - ); + this->_Error( "No valid first input image." ); } // eof - $RCSfile$ diff --git a/plugins/cpPluginsImageFilters/AndImageFilter.h b/plugins/cpPluginsImageFilters/AndImageFilter.h index 7eefcc6..bab353c 100644 --- a/plugins/cpPluginsImageFilters/AndImageFilter.h +++ b/plugins/cpPluginsImageFilters/AndImageFilter.h @@ -26,10 +26,10 @@ namespace cpPluginsImageFilters AndImageFilter( ); virtual ~AndImageFilter( ); - virtual std::string _GenerateData( ) ITK_OVERRIDE; + virtual void _GenerateData( ) ITK_OVERRIDE; template< class _TImage > - inline std::string _GD0( _TImage* image0 ); + inline void _GD0( _TImage* image0 ); private: // Purposely not implemented diff --git a/plugins/cpPluginsImageFilters/BinaryContourImageFilter.cxx b/plugins/cpPluginsImageFilters/BinaryContourImageFilter.cxx index 41bf3ef..2d45cd4 100644 --- a/plugins/cpPluginsImageFilters/BinaryContourImageFilter.cxx +++ b/plugins/cpPluginsImageFilters/BinaryContourImageFilter.cxx @@ -31,46 +31,37 @@ cpPluginsImageFilters::BinaryContourImageFilter:: } // ------------------------------------------------------------------------- -std::string cpPluginsImageFilters::BinaryContourImageFilter:: +void cpPluginsImageFilters::BinaryContourImageFilter:: _GenerateData( ) { auto image = this->GetInputData( "Input" )->GetITK< itk::DataObject >( ); - std::string cpPlugin_Image_Demangle_Pixel_AllScalars( r, _GD0, image, 2 ); - if( r != "" ) cpPlugin_Image_Demangle_Pixel_AllScalars( r, _GD0, image, 3 ); - return( r ); + cpPlugins_Image_Demangle_Pixel_AllScalars ( _GD0, image, 2 ); + else cpPlugins_Image_Demangle_Pixel_AllScalars( _GD0, image, 3 ); + else this->_Error( "No valid input image." ); } // ------------------------------------------------------------------------- template< class _TImage > -std::string cpPluginsImageFilters::BinaryContourImageFilter:: +void cpPluginsImageFilters::BinaryContourImageFilter:: _GD0( _TImage* image ) { + static const unsigned int D = _TImage::ImageDimension; if( image != NULL ) { std::string out_res = this->m_Parameters.GetSelectedChoice( "OutputResolution" ); if( out_res == "float" ) - return( - this->_GD1< _TImage, itk::Image< float, _TImage::ImageDimension > >( - image - ) - ); + this->_GD1< _TImage, itk::Image< float, D > >( image ); else // if( out_res == "double" ) - return( - this->_GD1< _TImage, itk::Image< double, _TImage::ImageDimension > >( - image - ) - ); + this->_GD1< _TImage, itk::Image< double, D > >( image ); } else - return( - "ImageFilters::BinaryContourImageFilter: No valid input image." - ); + this->_Error( "No valid input image." ); } // ------------------------------------------------------------------------- template< class _TImage, class _TContourImage > -std::string cpPluginsImageFilters::BinaryContourImageFilter:: +void cpPluginsImageFilters::BinaryContourImageFilter:: _GD1( _TImage* image ) { typedef itk::BinaryContourImageFilter< _TImage, _TContourImage > _F; @@ -90,7 +81,6 @@ _GD1( _TImage* image ) // Connect output this->GetOutputData( "Output" )->SetITK( filter->GetOutput( ) ); - return( "" ); } // eof - $RCSfile$ diff --git a/plugins/cpPluginsImageFilters/BinaryContourImageFilter.h b/plugins/cpPluginsImageFilters/BinaryContourImageFilter.h index 86181b6..cc66531 100644 --- a/plugins/cpPluginsImageFilters/BinaryContourImageFilter.h +++ b/plugins/cpPluginsImageFilters/BinaryContourImageFilter.h @@ -26,13 +26,13 @@ namespace cpPluginsImageFilters BinaryContourImageFilter( ); virtual ~BinaryContourImageFilter( ); - virtual std::string _GenerateData( ) ITK_OVERRIDE; + virtual void _GenerateData( ) ITK_OVERRIDE; template< class _TImage > - inline std::string _GD0( _TImage* image ); + inline void _GD0( _TImage* image ); template< class _TImage, class _TContourImage > - inline std::string _GD1( _TImage* image ); + inline void _GD1( _TImage* image ); private: // Purposely not implemented diff --git a/plugins/cpPluginsImageFilters/BinaryThresholdImageFilter.cxx b/plugins/cpPluginsImageFilters/BinaryThresholdImageFilter.cxx index 6c49a3e..9fcbc43 100644 --- a/plugins/cpPluginsImageFilters/BinaryThresholdImageFilter.cxx +++ b/plugins/cpPluginsImageFilters/BinaryThresholdImageFilter.cxx @@ -29,35 +29,29 @@ cpPluginsImageFilters::BinaryThresholdImageFilter:: } // ------------------------------------------------------------------------- -std::string cpPluginsImageFilters::BinaryThresholdImageFilter:: +void cpPluginsImageFilters::BinaryThresholdImageFilter:: _GenerateData( ) { auto image = this->GetInputData( "Input" )->GetITK< itk::DataObject >( ); - std::string cpPlugin_Image_Demangle_Pixel_AllScalars( r, _GD0, image, 2 ); - if( r != "" ) cpPlugin_Image_Demangle_Pixel_AllScalars( r, _GD0, image, 3 ); - /* TODO - if( r != "" ) cpPlugin_Image_Demangle_Pixel_AllScalars( r, _GD0, image, 1 ); - if( r != "" ) cpPlugin_Image_Demangle_Pixel_AllScalars( r, _GD0, image, 4 ); - */ - return( r ); + cpPlugins_Image_Demangle_Pixel_AllScalars ( _GD0, image, 2 ); + else cpPlugins_Image_Demangle_Pixel_AllScalars( _GD0, image, 3 ); + else this->_Error( "No valid input image." ); } // ------------------------------------------------------------------------- template< class _TImage > -std::string cpPluginsImageFilters::BinaryThresholdImageFilter:: +void cpPluginsImageFilters::BinaryThresholdImageFilter:: _GD0( _TImage* image ) { if( image != NULL ) - return( this->_GD1< _TImage, unsigned char >( image ) ); + this->_GD1< _TImage, unsigned char >( image ); else - return( - "ImageFilters::BinaryThresholdImageFilter: No valid input image." - ); + this->_Error( "No valid input image." ); } // ------------------------------------------------------------------------- template< class _TImage, class _TBinaryPixel > -std::string cpPluginsImageFilters::BinaryThresholdImageFilter:: +void cpPluginsImageFilters::BinaryThresholdImageFilter:: _GD1( _TImage* image ) { typedef itk::Image< _TBinaryPixel, _TImage::ImageDimension > _TBinaryImage; @@ -81,7 +75,6 @@ _GD1( _TImage* image ) // Connect output this->GetOutputData( "Output" )->SetITK( filter->GetOutput( ) ); - return( "" ); } // eof - $RCSfile$ diff --git a/plugins/cpPluginsImageFilters/BinaryThresholdImageFilter.h b/plugins/cpPluginsImageFilters/BinaryThresholdImageFilter.h index cc8590c..30a2208 100644 --- a/plugins/cpPluginsImageFilters/BinaryThresholdImageFilter.h +++ b/plugins/cpPluginsImageFilters/BinaryThresholdImageFilter.h @@ -26,13 +26,13 @@ namespace cpPluginsImageFilters BinaryThresholdImageFilter( ); virtual ~BinaryThresholdImageFilter( ); - virtual std::string _GenerateData( ) ITK_OVERRIDE; + virtual void _GenerateData( ) ITK_OVERRIDE; template< class _TImage > - inline std::string _GD0( _TImage* image ); + inline void _GD0( _TImage* image ); template< class _TImage, class _TBinaryPixel > - inline std::string _GD1( _TImage* image ); + inline void _GD1( _TImage* image ); private: // Purposely not implemented diff --git a/plugins/cpPluginsImageFilters/MultiScaleGaussianImageFilter.cxx b/plugins/cpPluginsImageFilters/MultiScaleGaussianImageFilter.cxx index 224aa87..f528e8e 100644 --- a/plugins/cpPluginsImageFilters/MultiScaleGaussianImageFilter.cxx +++ b/plugins/cpPluginsImageFilters/MultiScaleGaussianImageFilter.cxx @@ -2,30 +2,6 @@ #include #include -/* - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include - #include -*/ - // ------------------------------------------------------------------------- cpPluginsImageFilters::MultiScaleGaussianImageFilter:: MultiScaleGaussianImageFilter( ) @@ -50,38 +26,34 @@ cpPluginsImageFilters::MultiScaleGaussianImageFilter:: } // ------------------------------------------------------------------------- -std::string cpPluginsImageFilters::MultiScaleGaussianImageFilter:: +void cpPluginsImageFilters::MultiScaleGaussianImageFilter:: _GenerateData( ) { auto image = this->GetInputData( "Input" )->GetITK< itk::DataObject >( ); - std::string cpPlugin_Image_Demangle_Pixel_AllScalars( r, _GD0, image, 2 ); - if( r != "" ) cpPlugin_Image_Demangle_Pixel_AllScalars( r, _GD0, image, 3 ); - return( r ); + cpPlugins_Image_Demangle_Pixel_AllScalars ( _GD0, image, 2 ); + else cpPlugins_Image_Demangle_Pixel_AllScalars( _GD0, image, 3 ); + else this->_Error( "No valid input image." ); } // ------------------------------------------------------------------------- template< class _TImage > -std::string cpPluginsImageFilters::MultiScaleGaussianImageFilter:: +void cpPluginsImageFilters::MultiScaleGaussianImageFilter:: _GD0( _TImage* image ) { if( image != NULL ) { auto choice = this->m_Parameters.GetSelectedChoice( "ScalarType" ); - if( choice == "float" ) - return( this->_GD1< _TImage, float >( image ) ); - else if( choice == "double" ) - return( this->_GD1< _TImage, double >( image ) ); - else return( "MultiScaleGaussianImageFilter: no valid scalar type." ); + if ( choice == "float" ) this->_GD1< _TImage, float >( image ); + else if( choice == "double" ) this->_GD1< _TImage, double >( image ); + else this->_Error( "No valid scalar type." ); } else - return( - "MultiScaleGaussianImageFilter: No valid input image." - ); + this->_Error( "No valid input image." ); } // ------------------------------------------------------------------------- template< class _TImage, class _TScalar > -std::string cpPluginsImageFilters::MultiScaleGaussianImageFilter:: +void cpPluginsImageFilters::MultiScaleGaussianImageFilter:: _GD1( _TImage* image ) { typedef itk::CovariantVector< _TScalar, _TImage::ImageDimension > _TVector; @@ -92,9 +64,7 @@ _GD1( _TImage* image ) auto sigmas = this->m_Parameters.GetRealList( "Sigmas" ); if( sigmas.size( ) == 0 ) - return( - "MultiScaleGaussianImageFilter: No given sigmas." - ); + this->_Error( "No given sigmas." ); // Configure filter _TFilter* filter = this->_CreateITK< _TFilter >( ); @@ -105,7 +75,6 @@ _GD1( _TImage* image ) // Connect output this->GetOutputData( "Output" )->SetITK( filter->GetOutput( ) ); - return( "" ); } // eof - $RCSfile$ diff --git a/plugins/cpPluginsImageFilters/MultiScaleGaussianImageFilter.h b/plugins/cpPluginsImageFilters/MultiScaleGaussianImageFilter.h index 09bcc31..fa5bd17 100644 --- a/plugins/cpPluginsImageFilters/MultiScaleGaussianImageFilter.h +++ b/plugins/cpPluginsImageFilters/MultiScaleGaussianImageFilter.h @@ -26,13 +26,13 @@ namespace cpPluginsImageFilters MultiScaleGaussianImageFilter( ); virtual ~MultiScaleGaussianImageFilter( ); - virtual std::string _GenerateData( ) ITK_OVERRIDE; + virtual void _GenerateData( ) ITK_OVERRIDE; template< class _TImage > - inline std::string _GD0( _TImage* image ); + inline void _GD0( _TImage* image ); template< class _TImage, class _TScalar > - inline std::string _GD1( _TImage* image ); + inline void _GD1( _TImage* image ); private: // Purposely not implemented diff --git a/plugins/cpPluginsImageFilters/OrImageFilter.cxx b/plugins/cpPluginsImageFilters/OrImageFilter.cxx index 0d37b7b..5eb50ad 100644 --- a/plugins/cpPluginsImageFilters/OrImageFilter.cxx +++ b/plugins/cpPluginsImageFilters/OrImageFilter.cxx @@ -19,20 +19,24 @@ cpPluginsImageFilters::OrImageFilter:: } // ------------------------------------------------------------------------- -std::string cpPluginsImageFilters::OrImageFilter:: +void cpPluginsImageFilters::OrImageFilter:: _GenerateData( ) { auto image = this->GetInputData( "Input0" )->GetITK< itk::DataObject >( ); - std::string cpPlugin_Image_Demangle_Pixel_AllInts( r, _GD0, image, 2 ); - if( r != "" ) cpPlugin_Image_Demangle_Pixel_AllInts( r, _GD0, image, 3 ); - if( r != "" ) cpPlugin_Image_Demangle_Pixel_AllInts( r, _GD0, image, 1 ); - if( r != "" ) cpPlugin_Image_Demangle_Pixel_AllInts( r, _GD0, image, 4 ); - return( r ); + cpPlugins_Image_Demangle_Pixel_AllInts ( _GD0, image, 1 ); + else cpPlugins_Image_Demangle_Pixel_AllInts ( _GD0, image, 2 ); + else cpPlugins_Image_Demangle_Pixel_AllInts ( _GD0, image, 3 ); + else cpPlugins_Image_Demangle_Pixel_AllInts ( _GD0, image, 4 ); + else cpPlugins_Image_Demangle_Pixel_AllUInts( _GD0, image, 1 ); + else cpPlugins_Image_Demangle_Pixel_AllUInts( _GD0, image, 2 ); + else cpPlugins_Image_Demangle_Pixel_AllUInts( _GD0, image, 3 ); + else cpPlugins_Image_Demangle_Pixel_AllUInts( _GD0, image, 4 ); + else this->_Error( "No valid input image." ); } // ------------------------------------------------------------------------- template< class _TImage > -std::string cpPluginsImageFilters::OrImageFilter:: +void cpPluginsImageFilters::OrImageFilter:: _GD0( _TImage* image0 ) { typedef itk::OrImageFilter< _TImage, _TImage > _TFilter; @@ -49,17 +53,12 @@ _GD0( _TImage* image0 ) // Connect output this->GetOutputData( "Output" )->SetITK( filter->GetOutput( ) ); - return( "" ); } else - return( - "ImageFilters::OrImageFilter: No valid second input image." - ); + this->_Error( "No valid second input image." ); } else - return( - "ImageFilters::OrImageFilter: No valid first input image." - ); + this->_Error( "No valid first input image." ); } // eof - $RCSfile$ diff --git a/plugins/cpPluginsImageFilters/OrImageFilter.h b/plugins/cpPluginsImageFilters/OrImageFilter.h index 4ea5f4c..a970d61 100644 --- a/plugins/cpPluginsImageFilters/OrImageFilter.h +++ b/plugins/cpPluginsImageFilters/OrImageFilter.h @@ -26,10 +26,10 @@ namespace cpPluginsImageFilters OrImageFilter( ); virtual ~OrImageFilter( ); - virtual std::string _GenerateData( ) ITK_OVERRIDE; + virtual void _GenerateData( ) ITK_OVERRIDE; template< class _TImage > - inline std::string _GD0( _TImage* image0 ); + inline void _GD0( _TImage* image0 ); private: // Purposely not implemented diff --git a/plugins/cpPluginsImageFilters/ResampleImageFilter.cxx b/plugins/cpPluginsImageFilters/ResampleImageFilter.cxx index 8c9a8dd..8508189 100644 --- a/plugins/cpPluginsImageFilters/ResampleImageFilter.cxx +++ b/plugins/cpPluginsImageFilters/ResampleImageFilter.cxx @@ -23,42 +23,36 @@ cpPluginsImageFilters::ResampleImageFilter:: } // ------------------------------------------------------------------------- -std::string cpPluginsImageFilters::ResampleImageFilter:: +void cpPluginsImageFilters::ResampleImageFilter:: _GenerateData( ) { auto image = this->GetInputData( "Input" )->GetITK< itk::DataObject >( ); - std::string cpPlugin_Image_Demangle_Pixel_AllScalars( r, _GD0, image, 2 ); - if( r != "" ) cpPlugin_Image_Demangle_Pixel_AllScalars( r, _GD0, image, 3 ); - /* TODO - if( r != "" ) cpPlugin_Image_Demangle_Pixel_AllScalars( r, _GD0, image, 1 ); - if( r != "" ) cpPlugin_Image_Demangle_Pixel_AllScalars( r, _GD0, image, 4 ); - */ - return( r ); + cpPlugins_Image_Demangle_Pixel_AllScalars ( _GD0, image, 2 ); + else cpPlugins_Image_Demangle_Pixel_AllScalars( _GD0, image, 3 ); + else this->_Error( "No valid input image." ); } // ------------------------------------------------------------------------- template< class _TImage > -std::string cpPluginsImageFilters::ResampleImageFilter:: +void cpPluginsImageFilters::ResampleImageFilter:: _GD0( _TImage* image ) { if( image != NULL ) { auto choice = this->m_Parameters.GetSelectedChoice( "OutputResolution" ); if( choice == "float" ) - return( this->_GD1< _TImage, float >( image ) ); + this->_GD1< _TImage, float >( image ); else if( choice == "double" ) - return( this->_GD1< _TImage, double >( image ) ); - else return( "ResampleImageFilter: no valid scalar type." ); + this->_GD1< _TImage, double >( image ); + else this->_Error( "No valid scalar type." ); } else - return( - "ResampleImageFilter: No valid input image." - ); + this->_Error( "No valid input image." ); } // ------------------------------------------------------------------------- template< class _TImage, class _TScalar > -std::string cpPluginsImageFilters::ResampleImageFilter:: +void cpPluginsImageFilters::ResampleImageFilter:: _GD1( _TImage* image ) { typedef @@ -66,9 +60,7 @@ _GD1( _TImage* image ) _TFilter; if( image == NULL ) - return( - "ImageFilters::ResampleImageFilter: No valid input image." - ); + this->_Error( "No valid input image." ); // Configure filter _TFilter* filter = this->_CreateITK< _TFilter >( ); @@ -76,7 +68,6 @@ _GD1( _TImage* image ) // Connect output this->GetOutputData( "Output" )->SetITK( filter->GetOutput( ) ); - return( "" ); } // eof - $RCSfile$ diff --git a/plugins/cpPluginsImageFilters/ResampleImageFilter.h b/plugins/cpPluginsImageFilters/ResampleImageFilter.h index 14b6dbd..fe4124b 100644 --- a/plugins/cpPluginsImageFilters/ResampleImageFilter.h +++ b/plugins/cpPluginsImageFilters/ResampleImageFilter.h @@ -26,13 +26,13 @@ namespace cpPluginsImageFilters ResampleImageFilter( ); virtual ~ResampleImageFilter( ); - virtual std::string _GenerateData( ) ITK_OVERRIDE; + virtual void _GenerateData( ) ITK_OVERRIDE; template< class _TImage > - inline std::string _GD0( _TImage* image ); + inline void _GD0( _TImage* image ); template< class _TImage, class _TScalar > - inline std::string _GD1( _TImage* image ); + inline void _GD1( _TImage* image ); private: // Purposely not implemented diff --git a/plugins/cpPluginsImageFilters/SignedMaurerDistanceMapImageFilter.cxx b/plugins/cpPluginsImageFilters/SignedMaurerDistanceMapImageFilter.cxx index a0f29d8..05b9620 100644 --- a/plugins/cpPluginsImageFilters/SignedMaurerDistanceMapImageFilter.cxx +++ b/plugins/cpPluginsImageFilters/SignedMaurerDistanceMapImageFilter.cxx @@ -34,44 +34,39 @@ cpPluginsImageFilters::SignedMaurerDistanceMapImageFilter:: } // ------------------------------------------------------------------------- -std::string cpPluginsImageFilters::SignedMaurerDistanceMapImageFilter:: +void cpPluginsImageFilters::SignedMaurerDistanceMapImageFilter:: _GenerateData( ) { auto image = this->GetInputData( "Input" )->GetITK< itk::DataObject >( ); - std::string cpPlugin_Image_Demangle_Pixel_AllScalars( r, _GD0, image, 2 ); - if( r != "" ) cpPlugin_Image_Demangle_Pixel_AllScalars( r, _GD0, image, 3 ); - return( r ); + cpPlugins_Image_Demangle_Pixel_AllScalars ( _GD0, image, 2 ); + else cpPlugins_Image_Demangle_Pixel_AllScalars( _GD0, image, 3 ); + else this->_Error( "No valid input image." ); } // ------------------------------------------------------------------------- template< class _TImage > -std::string cpPluginsImageFilters::SignedMaurerDistanceMapImageFilter:: +void cpPluginsImageFilters::SignedMaurerDistanceMapImageFilter:: _GD0( _TImage* image ) { + static const unsigned int D = _TImage::ImageDimension; if( image != NULL ) { std::string out_res = this->m_Parameters.GetSelectedChoice( "OutputResolution" ); if( out_res == "float" ) - return( - this->_GD1< _TImage, itk::Image< float, _TImage::ImageDimension > >( image ) - ); - else if( out_res == "double" ) - return( - this->_GD1< _TImage, itk::Image< double, _TImage::ImageDimension > >( image ) - ); - else - return( "ImageFilters::SignedMaurerDistanceMapImageFilter: Output resolution not supported." ); + this->_GD1< _TImage, itk::Image< float, D > >( image ); + else if( out_res == "double" ) + this->_GD1< _TImage, itk::Image< double, D > >( image ); + else + this->_Error( "Output resolution not supported." ); } else - return( - "ImageFilters::SignedMaurerDistanceMapImageFilter: No valid input image." - ); + this->_Error( "No valid input image." ); } // ------------------------------------------------------------------------- template< class _TImage, class _TDMap > -std::string cpPluginsImageFilters::SignedMaurerDistanceMapImageFilter:: +void cpPluginsImageFilters::SignedMaurerDistanceMapImageFilter:: _GD1( _TImage* image ) { typedef itk::SignedMaurerDistanceMapImageFilter< _TImage, _TDMap > _F; @@ -93,7 +88,6 @@ _GD1( _TImage* image ) // Connect output this->GetOutputData( "Output" )->SetITK( filter->GetOutput( ) ); - return( "" ); } // eof - $RCSfile$ diff --git a/plugins/cpPluginsImageFilters/SignedMaurerDistanceMapImageFilter.h b/plugins/cpPluginsImageFilters/SignedMaurerDistanceMapImageFilter.h index c8fd23d..6aaf8d1 100644 --- a/plugins/cpPluginsImageFilters/SignedMaurerDistanceMapImageFilter.h +++ b/plugins/cpPluginsImageFilters/SignedMaurerDistanceMapImageFilter.h @@ -31,13 +31,13 @@ namespace cpPluginsImageFilters SignedMaurerDistanceMapImageFilter( ); virtual ~SignedMaurerDistanceMapImageFilter( ); - virtual std::string _GenerateData( ) ITK_OVERRIDE; + virtual void _GenerateData( ) ITK_OVERRIDE; template< class _TImage > - inline std::string _GD0( _TImage* image ); + inline void _GD0( _TImage* image ); template< class _TImage, class _TDMap > - inline std::string _GD1( _TImage* image ); + inline void _GD1( _TImage* image ); private: // Purposely not implemented diff --git a/plugins/cpPluginsImageMeshFilters/MarchingCubes.cxx b/plugins/cpPluginsImageMeshFilters/MarchingCubes.cxx index ff3c6fc..365cf49 100644 --- a/plugins/cpPluginsImageMeshFilters/MarchingCubes.cxx +++ b/plugins/cpPluginsImageMeshFilters/MarchingCubes.cxx @@ -23,14 +23,14 @@ cpPluginsImageMeshFilters::MarchingCubes:: } // ------------------------------------------------------------------------- -std::string cpPluginsImageMeshFilters::MarchingCubes:: +void cpPluginsImageMeshFilters::MarchingCubes:: _GenerateData( ) { // Get input auto image = this->GetInputData( "Input" ); vtkImageData* vtk_image = image->GetVTK< vtkImageData >( ); if( vtk_image == NULL ) - return( "MarchingCubes: Input does not have a valid VTK conversion." ); + this->_Error( "Input does not have a valid VTK conversion." ); std::vector< double > values = this->m_Parameters.GetRealList( "Thresholds" ); @@ -55,11 +55,10 @@ _GenerateData( ) pd = mc->GetOutput( ); } else - return( "MarchingCubes: Input data does not have a valid dimension." ); + this->_Error( "Input data does not have a valid dimension." ); // Connect output this->GetOutputData( "Output" )->SetVTK( pd ); - return( "" ); } // eof - $RCSfile$ diff --git a/plugins/cpPluginsImageMeshFilters/MarchingCubes.h b/plugins/cpPluginsImageMeshFilters/MarchingCubes.h index 08139c2..d951b7f 100644 --- a/plugins/cpPluginsImageMeshFilters/MarchingCubes.h +++ b/plugins/cpPluginsImageMeshFilters/MarchingCubes.h @@ -26,7 +26,7 @@ namespace cpPluginsImageMeshFilters MarchingCubes( ); virtual ~MarchingCubes( ); - virtual std::string _GenerateData( ) ITK_OVERRIDE; + virtual void _GenerateData( ) ITK_OVERRIDE; private: // Purposely not implemented diff --git a/plugins/cpPluginsImageMeshFilters/TriangleMeshToBinaryImageFilter.cxx b/plugins/cpPluginsImageMeshFilters/TriangleMeshToBinaryImageFilter.cxx index 6e35acc..4ee256f 100644 --- a/plugins/cpPluginsImageMeshFilters/TriangleMeshToBinaryImageFilter.cxx +++ b/plugins/cpPluginsImageMeshFilters/TriangleMeshToBinaryImageFilter.cxx @@ -30,7 +30,7 @@ cpPluginsImageMeshFilters::TriangleMeshToBinaryImageFilter:: } // ------------------------------------------------------------------------- -std::string cpPluginsImageMeshFilters::TriangleMeshToBinaryImageFilter:: +void cpPluginsImageMeshFilters::TriangleMeshToBinaryImageFilter:: _GenerateData( ) { typedef itk::Mesh< float, 3 > _3F; @@ -38,23 +38,22 @@ _GenerateData( ) auto _3f = this->GetInputData( "Input" )->GetITK< _3F >( ); auto _3d = this->GetInputData( "Input" )->GetITK< _3D >( ); - if ( _3f != NULL ) return( this->_GD0( _3f ) ); - else if( _3d != NULL ) return( this->_GD0( _3d ) ); - else - return( "TriangleMeshToBinaryImageFilter: No valid input itk mesh." ); + if ( _3f != NULL ) this->_GD0( _3f ); + else if( _3d != NULL ) this->_GD0( _3d ); + else this->_Error( "No valid input mesh." ); } // ------------------------------------------------------------------------- template< class _TMesh > -std::string cpPluginsImageMeshFilters::TriangleMeshToBinaryImageFilter:: +void cpPluginsImageMeshFilters::TriangleMeshToBinaryImageFilter:: _GD0( _TMesh* mesh ) { - return( this->_GD1< _TMesh, unsigned char >( mesh ) ); + this->_GD1< _TMesh, unsigned char >( mesh ); } // ------------------------------------------------------------------------- template< class _TMesh, class _TPixel > -std::string cpPluginsImageMeshFilters::TriangleMeshToBinaryImageFilter:: +void cpPluginsImageMeshFilters::TriangleMeshToBinaryImageFilter:: _GD1( _TMesh* mesh ) { typedef cpPlugins::BoundingBox _TBB; @@ -130,8 +129,6 @@ _GD1( _TMesh* mesh ) // Connect output auto out = this->GetOutputData( "Output" ); out->SetITK( filter->GetOutput( ) ); - return( "" ); - } // eof - $RCSfile$ diff --git a/plugins/cpPluginsImageMeshFilters/TriangleMeshToBinaryImageFilter.h b/plugins/cpPluginsImageMeshFilters/TriangleMeshToBinaryImageFilter.h index c917a3d..39d7163 100644 --- a/plugins/cpPluginsImageMeshFilters/TriangleMeshToBinaryImageFilter.h +++ b/plugins/cpPluginsImageMeshFilters/TriangleMeshToBinaryImageFilter.h @@ -26,13 +26,13 @@ namespace cpPluginsImageMeshFilters TriangleMeshToBinaryImageFilter( ); virtual ~TriangleMeshToBinaryImageFilter( ); - virtual std::string _GenerateData( ) ITK_OVERRIDE; + virtual void _GenerateData( ) ITK_OVERRIDE; template< class _TMesh > - inline std::string _GD0( _TMesh* mesh ); + inline void _GD0( _TMesh* mesh ); template< class _TMesh, class _TPixel > - inline std::string _GD1( _TMesh* mesh ); + inline void _GD1( _TMesh* mesh ); private: // Purposely not implemented diff --git a/plugins/cpPluginsMeshFilters/AppendMeshesFilter.cxx b/plugins/cpPluginsMeshFilters/AppendMeshesFilter.cxx index 4029c9c..f963274 100644 --- a/plugins/cpPluginsMeshFilters/AppendMeshesFilter.cxx +++ b/plugins/cpPluginsMeshFilters/AppendMeshesFilter.cxx @@ -24,7 +24,7 @@ cpPluginsMeshFilters::AppendMeshesFilter:: } // ------------------------------------------------------------------------- -std::string cpPluginsMeshFilters::AppendMeshesFilter:: +void cpPluginsMeshFilters::AppendMeshesFilter:: _GenerateData( ) { auto m0 = this->GetInputData( "Input0" )->GetVTK< vtkPolyData >( ); @@ -34,6 +34,9 @@ _GenerateData( ) auto m4 = this->GetInputData( "Input4" ); auto m5 = this->GetInputData( "Input5" ); + if( m0 == NULL || m1 == NULL ) + this->_Error( "Invalid inputs." ); + auto filter = this->_CreateVTK< vtkAppendPolyData >( ); filter->AddInputData( m0 ); filter->AddInputData( m1 ); @@ -44,7 +47,6 @@ _GenerateData( ) filter->Update( ); this->GetOutputData( "Output" )->SetVTK( filter->GetOutput( ) ); - return( "" ); } // eof - $RCSfile$ diff --git a/plugins/cpPluginsMeshFilters/AppendMeshesFilter.h b/plugins/cpPluginsMeshFilters/AppendMeshesFilter.h index 616e292..fd6aa0c 100644 --- a/plugins/cpPluginsMeshFilters/AppendMeshesFilter.h +++ b/plugins/cpPluginsMeshFilters/AppendMeshesFilter.h @@ -26,7 +26,7 @@ namespace cpPluginsMeshFilters AppendMeshesFilter( ); virtual ~AppendMeshesFilter( ); - virtual std::string _GenerateData( ) ITK_OVERRIDE; + virtual void _GenerateData( ) ITK_OVERRIDE; private: // Purposely not implemented diff --git a/plugins/cpPluginsWidgets/NoInteractiveSeedWidget.cxx b/plugins/cpPluginsWidgets/NoInteractiveSeedWidget.cxx index d5f8df8..a968a5b 100644 --- a/plugins/cpPluginsWidgets/NoInteractiveSeedWidget.cxx +++ b/plugins/cpPluginsWidgets/NoInteractiveSeedWidget.cxx @@ -23,18 +23,18 @@ cpPluginsWidgets::NoInteractiveSeedWidget:: } // ------------------------------------------------------------------------- -std::string cpPluginsWidgets::NoInteractiveSeedWidget:: +void cpPluginsWidgets::NoInteractiveSeedWidget:: _GenerateData( ) { auto image = this->GetInputData( "ReferenceImage" ); - std::string r = cpPlugin_Image_Demangle_Dim( _GD0, image, 3 ); - if( r != "" ) r = cpPlugin_Image_Demangle_Dim( _GD0, image, 2 ); - return( r ); + cpPlugins_Image_Demangle_Dim ( _GD0, image, 2 ); + else cpPlugins_Image_Demangle_Dim( _GD0, image, 3 ); + else this->_Error( "No valid input image." ); } // ------------------------------------------------------------------------- template< class _TImage > -std::string cpPluginsWidgets::NoInteractiveSeedWidget:: +void cpPluginsWidgets::NoInteractiveSeedWidget:: _GD0( _TImage* image ) { typedef @@ -58,10 +58,9 @@ _GD0( _TImage* image ) container->Get( ).push_back( idx ); container->SetReferenceImage( image ); this->GetOutputData( "Output" )->SetITK( container ); - return( "" ); } else - return( "Widgets::NoInteractiveSeedWidget: Input image dimension not supported." ); + this->_Error( "Input image dimension not supported." ); } // eof - $RCSfile$ diff --git a/plugins/cpPluginsWidgets/NoInteractiveSeedWidget.h b/plugins/cpPluginsWidgets/NoInteractiveSeedWidget.h index 9319879..492d2c5 100644 --- a/plugins/cpPluginsWidgets/NoInteractiveSeedWidget.h +++ b/plugins/cpPluginsWidgets/NoInteractiveSeedWidget.h @@ -26,10 +26,10 @@ namespace cpPluginsWidgets NoInteractiveSeedWidget( ); virtual ~NoInteractiveSeedWidget( ); - virtual std::string _GenerateData( ) ITK_OVERRIDE; + virtual void _GenerateData( ) ITK_OVERRIDE; template< class _TImage > - inline std::string _GD0( _TImage* image ); + inline void _GD0( _TImage* image ); private: // Purposely not implemented diff --git a/plugins/cpPluginsWidgets/SeedWidget.cxx b/plugins/cpPluginsWidgets/SeedWidget.cxx index b65d29f..20db639 100644 --- a/plugins/cpPluginsWidgets/SeedWidget.cxx +++ b/plugins/cpPluginsWidgets/SeedWidget.cxx @@ -33,18 +33,18 @@ cpPluginsWidgets::SeedWidget:: } // ------------------------------------------------------------------------- -std::string cpPluginsWidgets::SeedWidget:: +void cpPluginsWidgets::SeedWidget:: _GenerateData( ) { auto image = this->GetInputData( "ReferenceImage" ); - std::string r = cpPlugin_Image_Demangle_Dim( _GD0, image, 3 ); - if( r != "" ) r = cpPlugin_Image_Demangle_Dim( _GD0, image, 2 ); - return( r ); + cpPlugins_Image_Demangle_Dim ( _GD0, image, 2 ); + else cpPlugins_Image_Demangle_Dim( _GD0, image, 3 ); + else this->_Error( "No valid input image." ); } // ------------------------------------------------------------------------- template< class _TImage > -std::string cpPluginsWidgets::SeedWidget:: +void cpPluginsWidgets::SeedWidget:: _GD0( _TImage* image ) { typedef @@ -118,10 +118,9 @@ _GD0( _TImage* image ) this->m_Configured = true; container->SetReferenceImage( image ); this->GetOutputData( "Output" )->SetITK( container ); - return( "" ); } else - return( "Widgets::SeedWidget: Input image dimension not supported." ); + this->_Error( "Input image dimension not supported." ); } // eof - $RCSfile$ diff --git a/plugins/cpPluginsWidgets/SeedWidget.h b/plugins/cpPluginsWidgets/SeedWidget.h index 52f61c5..b53b346 100644 --- a/plugins/cpPluginsWidgets/SeedWidget.h +++ b/plugins/cpPluginsWidgets/SeedWidget.h @@ -29,10 +29,10 @@ namespace cpPluginsWidgets SeedWidget( ); virtual ~SeedWidget( ); - virtual std::string _GenerateData( ) ITK_OVERRIDE; + virtual void _GenerateData( ) ITK_OVERRIDE; template< class _TImage > - inline std::string _GD0( _TImage* image ); + inline void _GD0( _TImage* image ); private: // Purposely not implemented -- 2.47.1