From a89305e04527ebe2e81d0d1a62bbe34e0d35a141 Mon Sep 17 00:00:00 2001 From: Leonardo Florez-Valencia Date: Sat, 13 Feb 2016 17:24:36 -0500 Subject: [PATCH] ... --- lib/cpPlugins/Interface/DataObject.cxx | 6 +- lib/cpPlugins/Interface/Image.cxx | 12 +- lib/cpPlugins/Interface/Image.h | 6 +- lib/cpPlugins/Interface/Image.hxx | 112 ++++++++---------- lib/cpPlugins/Interface/ProcessObject.cxx | 15 +-- lib/cpPlugins/Interface/ProcessObject.hxx | 8 +- .../BasicFilters/BinaryErodeImageFilter.cxx | 9 +- .../BinaryThresholdImageFilter.cxx | 14 +-- .../Plugins/BasicFilters/CPRFilter.cxx | 11 +- lib/cpPlugins/Plugins/BasicFilters/Cutter.cxx | 7 +- .../BasicFilters/ExtractSliceImageFilter.cxx | 14 +-- .../BasicFilters/ImageInterpolatorSource.cxx | 5 +- .../BasicFilters/InputDataReproducer.cxx | 2 +- .../Plugins/BasicFilters/MacheteFilter.cxx | 6 +- .../BasicFilters/MacheteImageFilter.cxx | 18 +-- .../Plugins/BasicFilters/MarchingCubes.cxx | 4 +- .../BasicFilters/MedianImageFilter.cxx | 14 +-- .../BasicFilters/OtsuThresholdImageFilter.cxx | 14 +-- .../RGBImageToOtherChannelsFilter.cxx | 16 +-- .../SignedMaurerDistanceMapImageFilter.cxx | 14 +-- .../TriangleMeshToBinaryImageFilter.cxx | 14 +-- lib/cpPlugins/Plugins/IO/MeshReader.cxx | 10 +- 22 files changed, 121 insertions(+), 210 deletions(-) diff --git a/lib/cpPlugins/Interface/DataObject.cxx b/lib/cpPlugins/Interface/DataObject.cxx index 489392d..0bbe13b 100644 --- a/lib/cpPlugins/Interface/DataObject.cxx +++ b/lib/cpPlugins/Interface/DataObject.cxx @@ -80,8 +80,10 @@ DataObject( ) cpPlugins::Interface::DataObject:: ~DataObject( ) { - auto ptr = reinterpret_cast< ProcessObject::Pointer* >( this->m_Source ); - delete ptr; + /* TODO + auto ptr = reinterpret_cast< ProcessObject::Pointer* >( this->m_Source ); + delete ptr; + */ } // eof - $RCSfile$ diff --git a/lib/cpPlugins/Interface/Image.cxx b/lib/cpPlugins/Interface/Image.cxx index 44deb4e..b1f18f8 100644 --- a/lib/cpPlugins/Interface/Image.cxx +++ b/lib/cpPlugins/Interface/Image.cxx @@ -5,8 +5,16 @@ void cpPlugins::Interface::Image:: SetITK( itk::LightObject* o ) { this->Superclass::SetITK( o ); - this->_ITK_2_VTK_0< 2 >( o ); - this->_ITK_2_VTK_0< 3 >( o ); + bool success = false; + success |= this->_ITK_2_VTK_0< 2 >( o ); + success |= this->_ITK_2_VTK_0< 3 >( o ); + if( !success ) + { + this->m_VTKObject = NULL; + this->m_ITKvVTK = NULL; + + } // fi + this->Modified( ); } // ------------------------------------------------------------------------- diff --git a/lib/cpPlugins/Interface/Image.h b/lib/cpPlugins/Interface/Image.h index 45b47fa..88808c4 100644 --- a/lib/cpPlugins/Interface/Image.h +++ b/lib/cpPlugins/Interface/Image.h @@ -34,13 +34,13 @@ namespace cpPlugins virtual ~Image( ); template< unsigned int D > - inline void _ITK_2_VTK_0( itk::LightObject* o ); + inline bool _ITK_2_VTK_0( itk::LightObject* o ); template< class P, unsigned int D > - inline void _ITK_2_VTK_1( itk::LightObject* o ); + inline bool _ITK_2_VTK_1( itk::LightObject* o ); template< class I > - inline void _ITK_2_VTK_2( itk::LightObject* o ); + inline bool _ITK_2_VTK_2( itk::LightObject* o ); private: // Purposely not implemented diff --git a/lib/cpPlugins/Interface/Image.hxx b/lib/cpPlugins/Interface/Image.hxx index 1bb8b77..3160fea 100644 --- a/lib/cpPlugins/Interface/Image.hxx +++ b/lib/cpPlugins/Interface/Image.hxx @@ -17,79 +17,71 @@ // ------------------------------------------------------------------------- template< unsigned int D > -void cpPlugins::Interface::Image:: +bool cpPlugins::Interface::Image:: _ITK_2_VTK_0( itk::LightObject* o ) { + bool s = false; if( dynamic_cast< itk::ImageBase< D >* >( o ) != NULL ) { - this->_ITK_2_VTK_1< char, D >( o ); - this->_ITK_2_VTK_1< short, D >( o ); - this->_ITK_2_VTK_1< int, D >( o ); - this->_ITK_2_VTK_1< long, D >( o ); - this->_ITK_2_VTK_1< unsigned char, D >( o ); - this->_ITK_2_VTK_1< unsigned short, D >( o ); - this->_ITK_2_VTK_1< unsigned int, D >( o ); - this->_ITK_2_VTK_1< unsigned long, D >( o ); - this->_ITK_2_VTK_1< float, D >( o ); - this->_ITK_2_VTK_1< double, D >( o ); - this->_ITK_2_VTK_1< itk::RGBPixel< char >, D >( o ); - this->_ITK_2_VTK_1< itk::RGBPixel< short >, D >( o ); - this->_ITK_2_VTK_1< itk::RGBPixel< int >, D >( o ); - this->_ITK_2_VTK_1< itk::RGBPixel< long >, D >( o ); - this->_ITK_2_VTK_1< itk::RGBPixel< unsigned char >, D >( o ); - this->_ITK_2_VTK_1< itk::RGBPixel< unsigned short >, D >( o ); - this->_ITK_2_VTK_1< itk::RGBPixel< unsigned int >, D >( o ); - this->_ITK_2_VTK_1< itk::RGBPixel< unsigned long >, D >( o ); - this->_ITK_2_VTK_1< itk::RGBPixel< float >, D >( o ); - this->_ITK_2_VTK_1< itk::RGBPixel< double >, D >( o ); - this->_ITK_2_VTK_1< itk::RGBAPixel< char >, D >( o ); - this->_ITK_2_VTK_1< itk::RGBAPixel< short >, D >( o ); - this->_ITK_2_VTK_1< itk::RGBAPixel< int >, D >( o ); - this->_ITK_2_VTK_1< itk::RGBAPixel< long >, D >( o ); - this->_ITK_2_VTK_1< itk::RGBAPixel< unsigned char >, D >( o ); - this->_ITK_2_VTK_1< itk::RGBAPixel< unsigned short >, D >( o ); - this->_ITK_2_VTK_1< itk::RGBAPixel< unsigned int >, D >( o ); - this->_ITK_2_VTK_1< itk::RGBAPixel< unsigned long >, D >( o ); - this->_ITK_2_VTK_1< itk::RGBAPixel< float >, D >( o ); - this->_ITK_2_VTK_1< itk::RGBAPixel< double >, D >( o ); - this->_ITK_2_VTK_1< itk::DiffusionTensor3D< float >, D >( o ); - this->_ITK_2_VTK_1< itk::DiffusionTensor3D< double >, D >( o ); - this->_ITK_2_VTK_1< itk::Vector< float, D >, D >( o ); - this->_ITK_2_VTK_1< itk::Vector< double, D >, D >( o ); - this->_ITK_2_VTK_1< itk::CovariantVector< float, D >, D >( o ); - this->_ITK_2_VTK_1< itk::CovariantVector< double, D >, D >( o ); - this->_ITK_2_VTK_1< itk::Point< float, D >, D >( o ); - this->_ITK_2_VTK_1< itk::Point< double, D >, D >( o ); - this->_ITK_2_VTK_1< itk::SymmetricSecondRankTensor< float, D >, D >( o ); - this->_ITK_2_VTK_1< itk::SymmetricSecondRankTensor< double, D >, D >( o ); - } - else - { - this->m_VTKObject = NULL; - this->m_ITKvVTK = NULL; - this->Modified( ); + s |= this->_ITK_2_VTK_1< char, D >( o ); + s |= this->_ITK_2_VTK_1< short, D >( o ); + s |= this->_ITK_2_VTK_1< int, D >( o ); + s |= this->_ITK_2_VTK_1< long, D >( o ); + s |= this->_ITK_2_VTK_1< unsigned char, D >( o ); + s |= this->_ITK_2_VTK_1< unsigned short, D >( o ); + s |= this->_ITK_2_VTK_1< unsigned int, D >( o ); + s |= this->_ITK_2_VTK_1< unsigned long, D >( o ); + s |= this->_ITK_2_VTK_1< float, D >( o ); + s |= this->_ITK_2_VTK_1< double, D >( o ); + s |= this->_ITK_2_VTK_1< itk::RGBPixel< char >, D >( o ); + s |= this->_ITK_2_VTK_1< itk::RGBPixel< short >, D >( o ); + s |= this->_ITK_2_VTK_1< itk::RGBPixel< int >, D >( o ); + s |= this->_ITK_2_VTK_1< itk::RGBPixel< long >, D >( o ); + s |= this->_ITK_2_VTK_1< itk::RGBPixel< unsigned char >, D >( o ); + s |= this->_ITK_2_VTK_1< itk::RGBPixel< unsigned short >, D >( o ); + s |= this->_ITK_2_VTK_1< itk::RGBPixel< unsigned int >, D >( o ); + s |= this->_ITK_2_VTK_1< itk::RGBPixel< unsigned long >, D >( o ); + s |= this->_ITK_2_VTK_1< itk::RGBPixel< float >, D >( o ); + s |= this->_ITK_2_VTK_1< itk::RGBPixel< double >, D >( o ); + s |= this->_ITK_2_VTK_1< itk::RGBAPixel< char >, D >( o ); + s |= this->_ITK_2_VTK_1< itk::RGBAPixel< short >, D >( o ); + s |= this->_ITK_2_VTK_1< itk::RGBAPixel< int >, D >( o ); + s |= this->_ITK_2_VTK_1< itk::RGBAPixel< long >, D >( o ); + s |= this->_ITK_2_VTK_1< itk::RGBAPixel< unsigned char >, D >( o ); + s |= this->_ITK_2_VTK_1< itk::RGBAPixel< unsigned short >, D >( o ); + s |= this->_ITK_2_VTK_1< itk::RGBAPixel< unsigned int >, D >( o ); + s |= this->_ITK_2_VTK_1< itk::RGBAPixel< unsigned long >, D >( o ); + s |= this->_ITK_2_VTK_1< itk::RGBAPixel< float >, D >( o ); + s |= this->_ITK_2_VTK_1< itk::RGBAPixel< double >, D >( o ); + s |= this->_ITK_2_VTK_1< itk::DiffusionTensor3D< float >, D >( o ); + s |= this->_ITK_2_VTK_1< itk::DiffusionTensor3D< double >, D >( o ); + s |= this->_ITK_2_VTK_1< itk::Vector< float, D >, D >( o ); + s |= this->_ITK_2_VTK_1< itk::Vector< double, D >, D >( o ); + s |= this->_ITK_2_VTK_1< itk::CovariantVector< float, D >, D >( o ); + s |= this->_ITK_2_VTK_1< itk::CovariantVector< double, D >, D >( o ); + s |= this->_ITK_2_VTK_1< itk::Point< float, D >, D >( o ); + s |= this->_ITK_2_VTK_1< itk::Point< double, D >, D >( o ); + s |= this->_ITK_2_VTK_1< itk::SymmetricSecondRankTensor< float, D >, D >( o ); + s |= this->_ITK_2_VTK_1< itk::SymmetricSecondRankTensor< double, D >, D >( o ); } // fi + return( s ); } // ------------------------------------------------------------------------- template< class P, unsigned int D > -void cpPlugins::Interface::Image:: +bool cpPlugins::Interface::Image:: _ITK_2_VTK_1( itk::LightObject* o ) { - if( dynamic_cast< itk::Image< P, D >* >( o ) == NULL ) - { - this->m_VTKObject = NULL; - this->m_ITKvVTK = NULL; - this->Modified( ); - } + if( dynamic_cast< itk::Image< P, D >* >( o ) != NULL ) + return( this->_ITK_2_VTK_2< itk::Image< P, D > >( o ) ); else - this->_ITK_2_VTK_2< itk::Image< P, D > >( o ); + return( false ); } // ------------------------------------------------------------------------- template< class I > -void cpPlugins::Interface::Image:: +bool cpPlugins::Interface::Image:: _ITK_2_VTK_2( itk::LightObject* o ) { typedef itk::ImageToVTKImageFilter< I > _I2V; @@ -111,14 +103,10 @@ _ITK_2_VTK_2( itk::LightObject* o ) // Keep object track this->m_ITKObject = o; this->m_VTKObject = f->GetOutput( ); + return( true ); } else - { - this->m_VTKObject = NULL; - this->m_ITKvVTK = NULL; - - } // fi - this->Modified( ); + return( false ); } #ifndef cpPlugins_Interface_EXPORTS diff --git a/lib/cpPlugins/Interface/ProcessObject.cxx b/lib/cpPlugins/Interface/ProcessObject.cxx index e2ea0de..72897d6 100644 --- a/lib/cpPlugins/Interface/ProcessObject.cxx +++ b/lib/cpPlugins/Interface/ProcessObject.cxx @@ -154,7 +154,12 @@ Update( ) { bool iv = i->second.IsValid( ); bool ir = i->second.IsRequired( ); - if( iv || !ir ) + if( !iv && ir ) + r = + "ProcessObject: Required input \"" + + i->first + "@" + this->GetClassName( ) + + "\" is not valid (=NULL)."; + if( iv && r == "" ) { Self* src = dynamic_cast< Self* >( i->second->GetSource( ) ); if( src != NULL ) @@ -163,12 +168,8 @@ Update( ) r = src->Update( ); } // fi - } - else - r = - "ProcessObject: Required input \"" + - i->first + "@" + this->GetClassName( ) + - "\" is not valid (=NULL)."; + + } // fi } // rof diff --git a/lib/cpPlugins/Interface/ProcessObject.hxx b/lib/cpPlugins/Interface/ProcessObject.hxx index ccddc04..54c2f37 100644 --- a/lib/cpPlugins/Interface/ProcessObject.hxx +++ b/lib/cpPlugins/Interface/ProcessObject.hxx @@ -74,8 +74,8 @@ _CreateITK( ) if( filter == NULL ) { typename F::Pointer filter_ptr = F::New( ); - this->SetITK( filter_ptr.GetPointer( ) ); - this->SetVTK( NULL ); + this->m_ITKObject = filter_ptr; + this->m_VTKObject = NULL; filter = filter_ptr.GetPointer( ); this->Modified( ); @@ -92,8 +92,8 @@ _CreateVTK( ) if( filter == NULL ) { vtkSmartPointer< F > filter_ptr = vtkSmartPointer< F >::New( ); - this->SetITK( NULL ); - this->SetVTK( filter_ptr ); + this->m_ITKObject = NULL; + this->m_VTKObject = filter_ptr; filter = filter_ptr.GetPointer( ); this->Modified( ); diff --git a/lib/cpPlugins/Plugins/BasicFilters/BinaryErodeImageFilter.cxx b/lib/cpPlugins/Plugins/BasicFilters/BinaryErodeImageFilter.cxx index 0168f77..f4dd37b 100644 --- a/lib/cpPlugins/Plugins/BasicFilters/BinaryErodeImageFilter.cxx +++ b/lib/cpPlugins/Plugins/BasicFilters/BinaryErodeImageFilter.cxx @@ -76,13 +76,8 @@ _RealGD( itk::DataObject* image ) // Connect output auto out = this->GetOutputData< cpPlugins::Interface::Image >( "Output" ); - if( out != NULL ) - { - out->SetITK< O >( filter->GetOutput( ) ); - return( "" ); - } - else - return( "BinaryErodeImageFilter: output not correctly created." ); + out->SetITK( filter->GetOutput( ) ); + return( "" ); } // eof - $RCSfile$ diff --git a/lib/cpPlugins/Plugins/BasicFilters/BinaryThresholdImageFilter.cxx b/lib/cpPlugins/Plugins/BasicFilters/BinaryThresholdImageFilter.cxx index 9892679..af2c26a 100644 --- a/lib/cpPlugins/Plugins/BasicFilters/BinaryThresholdImageFilter.cxx +++ b/lib/cpPlugins/Plugins/BasicFilters/BinaryThresholdImageFilter.cxx @@ -8,7 +8,7 @@ cpPlugins::BasicFilters::BinaryThresholdImageFilter:: BinaryThresholdImageFilter( ) : Superclass( ) { - this->_AddInput( "Input", true ); + this->_AddInput( "Input" ); this->_AddOutput< cpPlugins::Interface::Image >( "Output" ); this->m_Parameters->ConfigureAsReal( "LowerThresholdValue" ); @@ -33,9 +33,6 @@ std::string cpPlugins::BasicFilters::BinaryThresholdImageFilter:: _GenerateData( ) { auto image = this->GetInputData< cpPlugins::Interface::Image >( "Input" ); - if( image == NULL ) - return( "BinaryThresholdImageFilter: No input image." ); - itk::DataObject* itk_image = NULL; std::string r = ""; cpPlugins_Image_Demangle_AllScalarTypes( 2, image, itk_image, r, _GD0 ); @@ -85,13 +82,8 @@ _RealGD( itk::DataObject* image ) // Connect output auto out = this->GetOutputData< cpPlugins::Interface::Image >( "Output" ); - if( out != NULL ) - { - out->SetITK< O >( filter->GetOutput( ) ); - return( "" ); - } - else - return( "BinaryThresholdImageFilter: output not correctly created." ); + out->SetITK( filter->GetOutput( ) ); + return( "" ); } // eof - $RCSfile$ diff --git a/lib/cpPlugins/Plugins/BasicFilters/CPRFilter.cxx b/lib/cpPlugins/Plugins/BasicFilters/CPRFilter.cxx index 21dcbab..a67baa1 100644 --- a/lib/cpPlugins/Plugins/BasicFilters/CPRFilter.cxx +++ b/lib/cpPlugins/Plugins/BasicFilters/CPRFilter.cxx @@ -9,8 +9,8 @@ cpPlugins::BasicFilters::CPRFilter:: CPRFilter( ) : Superclass( ) { - this->_AddInput( "InputImage", true ); - this->_AddInput( "InputAxis", true ); + this->_AddInput( "InputImage" ); + this->_AddInput( "InputAxis" ); this->_AddInput( "Interpolator", false ); this->_AddOutput< cpPlugins::Interface::Image >( "Output" ); @@ -38,9 +38,6 @@ _GenerateData( ) { auto image = this->GetInputData< cpPlugins::Interface::Image >( "InputImage" ); - if( image == NULL ) - return( "CPRFilter: No input image." ); - itk::DataObject* itk_image = NULL; std::string r = ""; cpPlugins_Image_Demangle_AllScalarTypes( 3, image, itk_image, r, _GD0 ); @@ -77,6 +74,8 @@ _GD1( I* image ) this->GetInputData< cpPlugins::Interface::PolyLineParametricPath >( "InputAxis" )->GetITK< _Path >( ); + if( axis == NULL ) + return( "CPRFilter: Invalid input axis." ); auto w_int = this->GetInputData< cpPlugins::Interface::DataObject >( "Interpolator" ); _Interpolator* interpolator = NULL; @@ -96,7 +95,7 @@ _GD1( I* image ) // Assign output auto out = this->GetOutputData< cpPlugins::Interface::Image >( "Output" ); - out->SetITK< I >( filter->GetOutput( ) ); + out->SetITK( filter->GetOutput( ) ); return( "" ); } diff --git a/lib/cpPlugins/Plugins/BasicFilters/Cutter.cxx b/lib/cpPlugins/Plugins/BasicFilters/Cutter.cxx index a0b051d..a6a916c 100644 --- a/lib/cpPlugins/Plugins/BasicFilters/Cutter.cxx +++ b/lib/cpPlugins/Plugins/BasicFilters/Cutter.cxx @@ -13,8 +13,8 @@ cpPlugins::BasicFilters::Cutter:: Cutter( ) : Superclass( ) { - this->_AddInput( "InputMesh", true ); - this->_AddInput( "InputFunction", true ); + this->_AddInput( "InputMesh" ); + this->_AddInput( "InputFunction" ); this->_AddOutput< cpPlugins::Interface::Mesh >( "Output" ); } @@ -34,9 +34,6 @@ _GenerateData( ) this->GetInputData< cpPlugins::Interface::ImplicitFunction >( "InputFunction" ); - if( function == NULL ) - return( "Cutter: Input data 1 is not a valid implicit function." ); - vtkCutter* cutter = this->_CreateVTK< vtkCutter >( ); cutter->DebugOn( ); cutter->SetInputData( mesh->GetVTK< vtkPolyData >( ) ); diff --git a/lib/cpPlugins/Plugins/BasicFilters/ExtractSliceImageFilter.cxx b/lib/cpPlugins/Plugins/BasicFilters/ExtractSliceImageFilter.cxx index 0e553fd..12cb540 100644 --- a/lib/cpPlugins/Plugins/BasicFilters/ExtractSliceImageFilter.cxx +++ b/lib/cpPlugins/Plugins/BasicFilters/ExtractSliceImageFilter.cxx @@ -8,7 +8,7 @@ cpPlugins::BasicFilters::ExtractSliceImageFilter:: ExtractSliceImageFilter( ) : Superclass( ) { - this->_AddInput( "Input", true ); + this->_AddInput( "Input" ); this->_AddOutput< cpPlugins::Interface::Image >( "Output" ); this->m_Parameters->ConfigureAsUint( "Axis" ); @@ -29,9 +29,6 @@ std::string cpPlugins::BasicFilters::ExtractSliceImageFilter:: _GenerateData( ) { auto image = this->GetInputData< cpPlugins::Interface::Image >( "Input" ); - if( image == NULL ) - return( "ExtractSliceImageFilter: No input image." ); - itk::DataObject* itk_image = NULL; std::string r = ""; /* @@ -80,13 +77,8 @@ _RealGD( itk::DataObject* image ) // Connect output auto out = this->GetOutputData< cpPlugins::Interface::Image >( "Output" ); - if( out != NULL ) - { - out->SetITK< O >( filter->GetOutput( ) ); - return( "" ); - } - else - return( "ExtractSliceImageFilter: output not correctly created." ); + out->SetITK( filter->GetOutput( ) ); + return( "" ); } // eof - $RCSfile$ diff --git a/lib/cpPlugins/Plugins/BasicFilters/ImageInterpolatorSource.cxx b/lib/cpPlugins/Plugins/BasicFilters/ImageInterpolatorSource.cxx index d47bc6e..0a1aa5c 100644 --- a/lib/cpPlugins/Plugins/BasicFilters/ImageInterpolatorSource.cxx +++ b/lib/cpPlugins/Plugins/BasicFilters/ImageInterpolatorSource.cxx @@ -9,7 +9,7 @@ cpPlugins::BasicFilters::ImageInterpolatorSource:: ImageInterpolatorSource( ) : Superclass( ) { - this->_AddInput( "ReferenceImage", true ); + this->_AddInput( "ReferenceImage" ); this->_AddOutput< cpPlugins::Interface::DataObject >( "Output" ); std::vector< std::string > type_choices; @@ -37,9 +37,6 @@ _GenerateData( ) { auto image = this->GetInputData< cpPlugins::Interface::Image >( "ReferenceImage" ); - if( image == NULL ) - return( "ImageInterpolatorSource: No input image." ); - itk::DataObject* itk_image = NULL; std::string r = ""; cpPlugins_Image_Demangle_AllScalarTypes( 2, image, itk_image, r, _GD0 ); diff --git a/lib/cpPlugins/Plugins/BasicFilters/InputDataReproducer.cxx b/lib/cpPlugins/Plugins/BasicFilters/InputDataReproducer.cxx index 022d469..957136d 100644 --- a/lib/cpPlugins/Plugins/BasicFilters/InputDataReproducer.cxx +++ b/lib/cpPlugins/Plugins/BasicFilters/InputDataReproducer.cxx @@ -5,7 +5,7 @@ cpPlugins::BasicFilters::InputDataReproducer:: InputDataReproducer( ) : Superclass( ) { - this->_AddInput( "Input", true ); + this->_AddInput( "Input" ); this->_AddOutput< cpPlugins::Interface::DataObject >( "Output" ); this->m_Parameters->Clear( ); } diff --git a/lib/cpPlugins/Plugins/BasicFilters/MacheteFilter.cxx b/lib/cpPlugins/Plugins/BasicFilters/MacheteFilter.cxx index 6877a3d..e8e9b10 100644 --- a/lib/cpPlugins/Plugins/BasicFilters/MacheteFilter.cxx +++ b/lib/cpPlugins/Plugins/BasicFilters/MacheteFilter.cxx @@ -194,7 +194,7 @@ MacheteFilter( ) : Superclass( ), m_PlaneWidget( NULL ) { - this->_AddInput( "Input", true ); + this->_AddInput( "Input" ); this->_AddOutput< cpPlugins::Interface::DataObject >( "PositiveOutput" ); this->_AddOutput< cpPlugins::Interface::DataObject >( "NegativeOutput" ); @@ -302,8 +302,8 @@ _RealImage( itk::DataObject* dobj ) } // fi // Assign outputs - pos_out->SetITK< I >( filter->GetPositiveOutput( ) ); - neg_out->SetITK< I >( filter->GetNegativeOutput( ) ); + pos_out->SetITK( filter->GetPositiveOutput( ) ); + neg_out->SetITK( filter->GetNegativeOutput( ) ); return( "" ); } diff --git a/lib/cpPlugins/Plugins/BasicFilters/MacheteImageFilter.cxx b/lib/cpPlugins/Plugins/BasicFilters/MacheteImageFilter.cxx index 772b9c2..7f9d251 100644 --- a/lib/cpPlugins/Plugins/BasicFilters/MacheteImageFilter.cxx +++ b/lib/cpPlugins/Plugins/BasicFilters/MacheteImageFilter.cxx @@ -12,7 +12,7 @@ cpPlugins::BasicFilters::MacheteImageFilter:: MacheteImageFilter() : Superclass() { - this->_AddInput( "Input", true ); + this->_AddInput( "Input" ); this->_AddOutput< cpPlugins::Interface::Image >("Output"); this->m_Parameters->ConfigureAsReal("Radius"); @@ -39,9 +39,6 @@ std::string cpPlugins::BasicFilters::MacheteImageFilter:: _GenerateData() { auto image = this->GetInputData< cpPlugins::Interface::Image >("Input"); - if (image == NULL) - return("MacheteImageFilter: No input image."); - itk::DataObject* itk_image = NULL; std::string r = ""; cpPlugins_Image_Demangle_AllScalarTypes(2, image, itk_image, r, _GD0); @@ -58,8 +55,8 @@ _GD0(itk::DataObject* image) { return( this->_RealGD< I, itk::Image< unsigned char, I::ImageDimension > >( - image - ) + image + ) ); } @@ -90,13 +87,8 @@ _RealGD(itk::DataObject* image) // Connect output auto out = this->GetOutputData< cpPlugins::Interface::Image >("Output"); - if (out != NULL) - { - out->SetITK< O >( filter->GetOutput( ) ); - return(""); - } - else - return("MacheteImageFilter: output not correctly created."); + out->SetITK( filter->GetOutput( ) ); + return(""); } // eof - $RCSfile$ diff --git a/lib/cpPlugins/Plugins/BasicFilters/MarchingCubes.cxx b/lib/cpPlugins/Plugins/BasicFilters/MarchingCubes.cxx index 0203b09..388b75e 100644 --- a/lib/cpPlugins/Plugins/BasicFilters/MarchingCubes.cxx +++ b/lib/cpPlugins/Plugins/BasicFilters/MarchingCubes.cxx @@ -11,7 +11,7 @@ cpPlugins::BasicFilters::MarchingCubes:: MarchingCubes( ) : Superclass( ) { - this->_AddInput( "Input", true ); + this->_AddInput( "Input" ); this->_AddOutput< cpPlugins::Interface::Mesh >( "Output" ); this->m_Parameters->ConfigureAsRealList( "Thresholds" ); @@ -29,8 +29,6 @@ _GenerateData( ) { // Get input auto image = this->GetInputData< cpPlugins::Interface::Image >( "Input" ); - if( image == NULL ) - return( "MarchingCubes: Input data is not a valid image." ); vtkImageData* vtk_image = image->GetVTK< vtkImageData >( ); if( vtk_image == NULL ) return( "MarchingCubes: Input does not have a valid VTK conversion." ); diff --git a/lib/cpPlugins/Plugins/BasicFilters/MedianImageFilter.cxx b/lib/cpPlugins/Plugins/BasicFilters/MedianImageFilter.cxx index 2e4c763..0046f07 100644 --- a/lib/cpPlugins/Plugins/BasicFilters/MedianImageFilter.cxx +++ b/lib/cpPlugins/Plugins/BasicFilters/MedianImageFilter.cxx @@ -8,7 +8,7 @@ cpPlugins::BasicFilters::MedianImageFilter:: MedianImageFilter( ) : Superclass( ) { - this->_AddInput( "Input", true ); + this->_AddInput( "Input" ); this->_AddOutput< cpPlugins::Interface::Image >( "Output" ); this->m_Parameters->ConfigureAsUint( "Radius" ); @@ -26,9 +26,6 @@ std::string cpPlugins::BasicFilters::MedianImageFilter:: _GenerateData( ) { auto image = this->GetInputData< cpPlugins::Interface::Image >( "Input" ); - if( image == NULL ) - return( "MedianImageFilter: No input image." ); - itk::DataObject* itk_image = NULL; std::string r = ""; cpPlugins_Image_Demangle_AllScalarTypes( 2, image, itk_image, r, _GD0 ); @@ -70,13 +67,8 @@ _RealGD( itk::DataObject* image ) // Connect output auto out = this->GetOutputData< cpPlugins::Interface::Image >( "Output" ); - if( out != NULL ) - { - out->SetITK< O >( filter->GetOutput( ) ); - return( "" ); - } - else - return( "MedianImageFilter: output not correctly created." ); + out->SetITK( filter->GetOutput( ) ); + return( "" ); } // eof - $RCSfile$ diff --git a/lib/cpPlugins/Plugins/BasicFilters/OtsuThresholdImageFilter.cxx b/lib/cpPlugins/Plugins/BasicFilters/OtsuThresholdImageFilter.cxx index 0c4852b..5c419ae 100644 --- a/lib/cpPlugins/Plugins/BasicFilters/OtsuThresholdImageFilter.cxx +++ b/lib/cpPlugins/Plugins/BasicFilters/OtsuThresholdImageFilter.cxx @@ -8,7 +8,7 @@ cpPlugins::BasicFilters::OtsuThresholdImageFilter:: OtsuThresholdImageFilter( ) : Superclass( ) { - this->_AddInput( "Input", true ); + this->_AddInput( "Input" ); this->_AddOutput< cpPlugins::Interface::Image >( "Output" ); this->m_Parameters->ConfigureAsUint( "NumberOfHistogramBins" ); @@ -31,9 +31,6 @@ std::string cpPlugins::BasicFilters::OtsuThresholdImageFilter:: _GenerateData( ) { auto image = this->GetInputData< cpPlugins::Interface::Image >( "Input" ); - if( image == NULL ) - return( "OtsuThresholdImageFilter: No input image." ); - itk::DataObject* itk_image = NULL; std::string r = ""; cpPlugins_Image_Demangle_AllScalarTypes( 2, image, itk_image, r, _GD0 ); @@ -78,13 +75,8 @@ _RealGD( itk::DataObject* image ) // Connect output auto out = this->GetOutputData< cpPlugins::Interface::Image >( "Output" ); - if( out != NULL ) - { - out->SetITK< O >( filter->GetOutput( ) ); - return( "" ); - } - else - return( "OtsuThresholdImageFilter: output not correctly created." ); + out->SetITK( filter->GetOutput( ) ); + return( "" ); } // eof - $RCSfile$ diff --git a/lib/cpPlugins/Plugins/BasicFilters/RGBImageToOtherChannelsFilter.cxx b/lib/cpPlugins/Plugins/BasicFilters/RGBImageToOtherChannelsFilter.cxx index 700043d..f7fdfff 100644 --- a/lib/cpPlugins/Plugins/BasicFilters/RGBImageToOtherChannelsFilter.cxx +++ b/lib/cpPlugins/Plugins/BasicFilters/RGBImageToOtherChannelsFilter.cxx @@ -11,9 +11,7 @@ cpPlugins::BasicFilters::RGBImageToOtherChannelsFilter:: RGBImageToOtherChannelsFilter( ) : Superclass( ) { - typedef cpPlugins::Interface::Parameters TParameters; - - this->_AddInput( "Input", true ); + this->_AddInput( "Input" ); this->_AddOutput< cpPlugins::Interface::Image >( "Output" ); std::vector< std::string > choices; @@ -33,9 +31,6 @@ std::string cpPlugins::BasicFilters::RGBImageToOtherChannelsFilter:: _GenerateData( ) { auto image = this->GetInputData< cpPlugins::Interface::Image >( "Input" ); - if( image == NULL ) - return( "RGBImageToOtherChannelsFilter: No input image." ); - itk::DataObject* itk_image = NULL; std::string r = ""; cpPlugins_Image_Demangle_AllRGBTypes( 2, image, itk_image, r, _GD0 ); @@ -86,14 +81,7 @@ _RealGD( itk::DataObject* image ) // Connect output auto out = this->GetOutputData< cpPlugins::Interface::Image >( "Output" ); - if( out != NULL ) - { - out->SetITK< _O >( filter->GetOutput( ) ); - return( "" ); - } - else - return( "RGBImageToOtherChannelsFilter: output not correctly created." ); - + out->SetITK( filter->GetOutput( ) ); return( "" ); } diff --git a/lib/cpPlugins/Plugins/BasicFilters/SignedMaurerDistanceMapImageFilter.cxx b/lib/cpPlugins/Plugins/BasicFilters/SignedMaurerDistanceMapImageFilter.cxx index 4748675..90fa019 100644 --- a/lib/cpPlugins/Plugins/BasicFilters/SignedMaurerDistanceMapImageFilter.cxx +++ b/lib/cpPlugins/Plugins/BasicFilters/SignedMaurerDistanceMapImageFilter.cxx @@ -8,7 +8,7 @@ cpPlugins::BasicFilters::SignedMaurerDistanceMapImageFilter:: SignedMaurerDistanceMapImageFilter( ) : Superclass( ) { - this->_AddInput( "Input", true ); + this->_AddInput( "Input" ); this->_AddOutput< cpPlugins::Interface::Image >( "Output" ); this->m_Parameters->ConfigureAsReal( "BackgroundValue" ); @@ -39,9 +39,6 @@ std::string cpPlugins::BasicFilters::SignedMaurerDistanceMapImageFilter:: _GenerateData( ) { auto image = this->GetInputData< cpPlugins::Interface::Image >( "Input" ); - if( image == NULL ) - return( "SignedMaurerDistanceMapImageFilter: No input image." ); - itk::DataObject* itk_image = NULL; std::string r = ""; cpPlugins_Image_Demangle_AllScalarTypes( 2, image, itk_image, r, _GD0 ); @@ -98,13 +95,8 @@ _RealGD( itk::DataObject* image ) // Connect output auto out = this->GetOutputData< cpPlugins::Interface::Image >( "Output" ); - if( out != NULL ) - { - out->SetITK< O >( filter->GetOutput( ) ); - return( "" ); - } - else - return( "SignedMaurerDistanceMapImageFilter: output not correctly created." ); + out->SetITK( filter->GetOutput( ) ); + return( "" ); } // eof - $RCSfile$ diff --git a/lib/cpPlugins/Plugins/BasicFilters/TriangleMeshToBinaryImageFilter.cxx b/lib/cpPlugins/Plugins/BasicFilters/TriangleMeshToBinaryImageFilter.cxx index e380029..5dc3f68 100644 --- a/lib/cpPlugins/Plugins/BasicFilters/TriangleMeshToBinaryImageFilter.cxx +++ b/lib/cpPlugins/Plugins/BasicFilters/TriangleMeshToBinaryImageFilter.cxx @@ -10,7 +10,7 @@ cpPlugins::BasicFilters::TriangleMeshToBinaryImageFilter:: TriangleMeshToBinaryImageFilter( ) : Superclass( ) { - this->_AddInput( "Input", true ); + this->_AddInput( "Input" ); this->_AddOutput< cpPlugins::Interface::Image >( "Output" ); this->m_Parameters->ConfigureAsUint( "InsideValue" ); @@ -36,9 +36,6 @@ _GenerateData( ) typedef itk::Mesh< double, 3 > _3D; auto input = this->GetInputData< cpPlugins::Interface::Mesh >( "Input" ); - if( input == NULL ) - return( "TriangleMeshToBinaryImageFilter: No valid input mesh." ); - auto in_3f = input->GetITK< _3F >( ); auto in_3d = input->GetITK< _3D >( ); if ( in_3f != NULL ) return( this->_GD0( in_3f ) ); @@ -120,13 +117,8 @@ _RealGD( M* mesh ) // Connect output auto out = this->GetOutputData< cpPlugins::Interface::Image >( "Output" ); - if( out != NULL ) - { - out->SetITK< I >( filter->GetOutput( ) ); - return( "" ); - } - else - return( "TriangleMeshToBinaryImageFilter: output not correctly created." ); + out->SetITK( filter->GetOutput( ) ); + return( "" ); } // eof - $RCSfile$ diff --git a/lib/cpPlugins/Plugins/IO/MeshReader.cxx b/lib/cpPlugins/Plugins/IO/MeshReader.cxx index c820c68..943d3ac 100644 --- a/lib/cpPlugins/Plugins/IO/MeshReader.cxx +++ b/lib/cpPlugins/Plugins/IO/MeshReader.cxx @@ -85,10 +85,7 @@ _GD1( ) stlr->Update( ); auto out = this->GetOutputData< cpPlugins::Interface::Mesh >( "Output" ); - if( out != NULL ) - out->SetVTK( stlr->GetOutput( ) ); - else - return( "MeshReader: output not correctly created." ); + out->SetVTK( stlr->GetOutput( ) ); return( "" ); } else if( ext == "obj" ) @@ -102,10 +99,7 @@ _GD1( ) pdr->Update( ); auto out = this->GetOutputData< cpPlugins::Interface::Mesh >( "Output" ); - if( out != NULL ) - out->SetVTK( pdr->GetOutput( ) ); - else - return( "MeshReader: output not correctly created." ); + out->SetVTK( pdr->GetOutput( ) ); return( "" ); } // fi -- 2.45.2