From 2a4d9263fd7004405f8638a2882550fb77d661d4 Mon Sep 17 00:00:00 2001 From: Leonardo Florez-Valencia Date: Sat, 13 Feb 2016 17:25:02 -0500 Subject: [PATCH] ... --- .../AllPixelsImageGrowFunctionSource.cxx | 21 +-- lib/fpaPlugins/BaseImageFilter.cxx | 14 ++ lib/fpaPlugins/BaseImageFilter.h | 93 ++--------- lib/fpaPlugins/BaseImageFilter.hxx | 148 ++++++++++++++++++ lib/fpaPlugins/GrowFunction.cxx | 7 + lib/fpaPlugins/GrowFunction.h | 3 +- lib/fpaPlugins/GrowFunction.hxx | 21 +-- lib/fpaPlugins/ImageDijkstra.cxx | 74 +-------- lib/fpaPlugins/ImageRegionGrow.cxx | 75 ++------- lib/fpaPlugins/MinimumSpanningTree.cxx | 7 + lib/fpaPlugins/MinimumSpanningTree.h | 3 +- lib/fpaPlugins/MinimumSpanningTree.hxx | 15 +- lib/fpaPlugins/MinimumSpanningTreeToMesh.cxx | 8 - .../ThresholdImageGrowFunctionSource.cxx | 23 ++- 14 files changed, 224 insertions(+), 288 deletions(-) create mode 100644 lib/fpaPlugins/BaseImageFilter.hxx diff --git a/lib/fpaPlugins/AllPixelsImageGrowFunctionSource.cxx b/lib/fpaPlugins/AllPixelsImageGrowFunctionSource.cxx index 89a683c..7e76aef 100644 --- a/lib/fpaPlugins/AllPixelsImageGrowFunctionSource.cxx +++ b/lib/fpaPlugins/AllPixelsImageGrowFunctionSource.cxx @@ -26,15 +26,11 @@ _GenerateData( ) { auto image = this->GetInputData< cpPlugins::Interface::Image >( "ReferenceImage" ); - if( image == NULL ) - return( "fpaPlugins::AllPixelsImageGrowFunctionSource: No input reference image." ); - itk::DataObject* itk_image = NULL; std::string r = ""; cpPlugins_Image_Demangle_AllScalarTypes( 2, image, itk_image, r, _GD0 ); else cpPlugins_Image_Demangle_AllScalarTypes( 3, image, itk_image, r, _GD0 ); else r = "fpaPlugins::AllPixelsImageGrowFunctionSource: no valid reference image."; - return( r ); } @@ -44,17 +40,16 @@ std::string fpaPlugins::AllPixelsImageGrowFunctionSource:: _GD0( itk::DataObject* data ) { typedef fpa::Image::Functors::RegionGrowAllBelongsFunction< I > _F; - typename _F::Pointer functor = _F::New( ); - - // Connect output auto out = this->GetOutputData< GrowFunction >( "Output" ); - if( out != NULL ) + auto f = out->GetITK< _F >( ); + if( f == NULL ) { - out->SetITK< _F >( functor ); - return( "" ); - } - else - return( "fpaPlugins::AllPixelsImageGrowFunctionSource: output not correctly created." ); + typename _F::Pointer ptr_f = _F::New( ); + f = ptr_f.GetPointer( ); + out->SetITK( f ); + + } // fi + return( "" ); } // eof - $RCSfile$ diff --git a/lib/fpaPlugins/BaseImageFilter.cxx b/lib/fpaPlugins/BaseImageFilter.cxx index 422d83b..19a1533 100644 --- a/lib/fpaPlugins/BaseImageFilter.cxx +++ b/lib/fpaPlugins/BaseImageFilter.cxx @@ -5,6 +5,20 @@ fpaPlugins::BaseImageFilter:: BaseImageFilter( ) : Superclass( ) { + this->_AddInput( "Input" ); + this->_AddInput( "Seeds" ); + this->_AddOutput< cpPlugins::Interface::Image >( "Output" ); + + this->m_Parameters->ConfigureAsBool( "VisualDebug" ); + this->m_Parameters->ConfigureAsBool( "StopAtOneFront" ); + this->m_Parameters->SetBool( "VisualDebug", false ); + this->m_Parameters->SetBool( "StopAtOneFront", false ); + + std::vector< std::string > orders; + orders.push_back( "1" ); + orders.push_back( "2" ); + this->m_Parameters->ConfigureAsChoices( "NeighborhoodOrder", orders ); + this->m_Parameters->SetSelectedChoice( "NeighborhoodOrder", "1" ); } // ------------------------------------------------------------------------- diff --git a/lib/fpaPlugins/BaseImageFilter.h b/lib/fpaPlugins/BaseImageFilter.h index 991a2c0..2deeb5b 100644 --- a/lib/fpaPlugins/BaseImageFilter.h +++ b/lib/fpaPlugins/BaseImageFilter.h @@ -30,10 +30,16 @@ namespace fpaPlugins virtual ~BaseImageFilter( ); template< class F > - void _ConfigureDebugger( F* filter ); + inline F* _ConfigureFilter( ); template< class F > - void _DeconfigureDebugger( F* filter ); + inline void _ExecuteFilter( F* filter ); + + template< class F > + inline void _ConfigureDebugger( F* filter ); + + template< class F > + inline void _DeconfigureDebugger( F* filter ); private: // Purposely not implemented. @@ -46,88 +52,7 @@ namespace fpaPlugins } // ecapseman -// ------------------------------------------------------------------------- -#include -#include -#include -#include - -// ------------------------------------------------------------------------- -template< class F > -void fpaPlugins::BaseImageFilter:: -_ConfigureDebugger( F* filter ) -{ - typedef typename F::TInputImage _I; - typedef fpa::VTK::Image2DObserver< F, vtkRenderWindow > _2D; - typedef fpa::VTK::Image3DObserver< F, vtkRenderWindow > _3D; - - this->m_Observers.clear( ); - if( this->m_Parameters->GetBool( "VisualDebug" ) ) - { - if( this->m_MPRViewer != NULL ) - { - if( _I::ImageDimension == 2 ) - { - auto iren = this->m_MPRViewer->GetInteractor( 2 ); - if( iren != NULL ) - { - typename _2D::Pointer debugger = _2D::New( ); - debugger->SetRenderWindow( iren->GetRenderWindow( ) ); - debugger->SetRenderPercentage( 0.01 ); - this->m_Observers.insert( - filter->AddObserver( itk::AnyEvent( ), debugger ) - ); - filter->ThrowEventsOn( ); - - } // fi - } - else if( _I::ImageDimension == 3 ) - { - auto iren = this->m_MPRViewer->GetInteractor( 2 ); - if( iren != NULL ) - { - typename _3D::Pointer debugger = _3D::New( ); - debugger->SetRenderWindow( iren->GetRenderWindow( ) ); - debugger->SetRenderPercentage( 0.001 ); - this->m_Observers.insert( - filter->AddObserver( itk::AnyEvent( ), debugger ) - ); - filter->ThrowEventsOn( ); - - } // fi - - } // fi - - } // fi - - if( this->m_SingleInteractor != NULL ) - { - if( _I::ImageDimension == 2 ) - { - } - else if( _I::ImageDimension == 3 ) - { - } // fi - - } // fi - - } // fi -} - -// ------------------------------------------------------------------------- -template< class F > -void fpaPlugins::BaseImageFilter:: -_DeconfigureDebugger( F* filter ) -{ - if( filter != NULL ) - { - auto oIt = this->m_Observers.begin( ); - for( ; oIt != this->m_Observers.end( ); ++oIt ) - filter->RemoveObserver( *oIt ); - - } // fi - this->m_Observers.clear( ); -} +#include #endif // __FPAPLUGINS__BASEIMAGEFILTER__H__ diff --git a/lib/fpaPlugins/BaseImageFilter.hxx b/lib/fpaPlugins/BaseImageFilter.hxx new file mode 100644 index 0000000..22d8837 --- /dev/null +++ b/lib/fpaPlugins/BaseImageFilter.hxx @@ -0,0 +1,148 @@ +#ifndef __FPAPLUGINS__BASEIMAGEFILTER__HXX__ +#define __FPAPLUGINS__BASEIMAGEFILTER__HXX__ + +#include +#include +#include + +#include +#include + +#include + +// ------------------------------------------------------------------------- +template< class F > +F* fpaPlugins::BaseImageFilter:: +_ConfigureFilter( ) +{ + typedef typename F::TInputImage _I; + typedef typename _I::PointType _P; + + auto image = + this->GetInputData< cpPlugins::Interface::Image >( "Input" )-> + GetITK< _I >( ); + auto seeds = + this->GetInputData< cpPlugins::Interface::PointList >( "Seeds" ); + + // Create filter and connect input + F* filter = this->_CreateITK< F >( ); + filter->SetInput( image ); + + // Set numeric parameters + Superclass::TParameters* params = this->m_Parameters; + filter->SetNeighborhoodOrder( + params->GetSelectedChoice( "NeighborhoodOrder" )[ 0 ] - '0' + ); + filter->SetStopAtOneFront( params->GetBool( "StopAtOneFront" ) ); + + // Assign seeds + filter->ClearSeeds( ); + for( unsigned int s = 0; s < seeds->GetNumberOfPoints( ); ++s ) + { + _P pnt = seeds->GetPoint< _P >( s ); + typename _I::IndexType idx; + if( image->TransformPhysicalPointToIndex( pnt, idx ) ) + filter->AddSeed( idx, 0 ); + + } // rof + + // Ok! + return( filter ); +} + +// ------------------------------------------------------------------------- +template< class F > +void fpaPlugins::BaseImageFilter:: +_ExecuteFilter( F* filter ) +{ + // Go!!! + this->_ConfigureDebugger( filter ); + filter->Update( ); + this->_DeconfigureDebugger( filter ); + + // Connect output + auto out = + this->GetOutputData< cpPlugins::Interface::Image >( "Output" ); + out->SetITK( filter->GetOutput( ) ); +} + +// ------------------------------------------------------------------------- +template< class F > +void fpaPlugins::BaseImageFilter:: +_ConfigureDebugger( F* filter ) +{ + typedef typename F::TInputImage _I; + typedef fpa::VTK::Image2DObserver< F, vtkRenderWindow > _2D; + typedef fpa::VTK::Image3DObserver< F, vtkRenderWindow > _3D; + + this->m_Observers.clear( ); + if( this->m_Parameters->GetBool( "VisualDebug" ) ) + { + if( this->m_MPRViewer != NULL ) + { + if( _I::ImageDimension == 2 ) + { + auto iren = this->m_MPRViewer->GetInteractor( 2 ); + if( iren != NULL ) + { + typename _2D::Pointer debugger = _2D::New( ); + debugger->SetRenderWindow( iren->GetRenderWindow( ) ); + debugger->SetRenderPercentage( 0.01 ); + this->m_Observers.insert( + filter->AddObserver( itk::AnyEvent( ), debugger ) + ); + filter->ThrowEventsOn( ); + + } // fi + } + else if( _I::ImageDimension == 3 ) + { + auto iren = this->m_MPRViewer->GetInteractor( 2 ); + if( iren != NULL ) + { + typename _3D::Pointer debugger = _3D::New( ); + debugger->SetRenderWindow( iren->GetRenderWindow( ) ); + debugger->SetRenderPercentage( 0.001 ); + this->m_Observers.insert( + filter->AddObserver( itk::AnyEvent( ), debugger ) + ); + filter->ThrowEventsOn( ); + + } // fi + + } // fi + + } // fi + + if( this->m_SingleInteractor != NULL ) + { + if( _I::ImageDimension == 2 ) + { + } + else if( _I::ImageDimension == 3 ) + { + } // fi + + } // fi + + } // fi +} + +// ------------------------------------------------------------------------- +template< class F > +void fpaPlugins::BaseImageFilter:: +_DeconfigureDebugger( F* filter ) +{ + if( filter != NULL ) + { + auto oIt = this->m_Observers.begin( ); + for( ; oIt != this->m_Observers.end( ); ++oIt ) + filter->RemoveObserver( *oIt ); + + } // fi + this->m_Observers.clear( ); +} + +#endif // __FPAPLUGINS__BASEIMAGEFILTER__HXX__ + +// eof - $RCSfile$ diff --git a/lib/fpaPlugins/GrowFunction.cxx b/lib/fpaPlugins/GrowFunction.cxx index 9b6d0d9..8cc392f 100644 --- a/lib/fpaPlugins/GrowFunction.cxx +++ b/lib/fpaPlugins/GrowFunction.cxx @@ -1,5 +1,12 @@ #include +// ------------------------------------------------------------------------- +void fpaPlugins::GrowFunction:: +SetVTK( vtkObjectBase* o ) +{ + // Do nothing: this has only sense in ITK +} + // ------------------------------------------------------------------------- fpaPlugins::GrowFunction:: GrowFunction( ) diff --git a/lib/fpaPlugins/GrowFunction.h b/lib/fpaPlugins/GrowFunction.h index cca92ab..9bcd887 100644 --- a/lib/fpaPlugins/GrowFunction.h +++ b/lib/fpaPlugins/GrowFunction.h @@ -26,8 +26,7 @@ namespace fpaPlugins cpPlugins_Id_Macro( GrowFunction, GrowFunction ); public: - template< class F > - inline void SetITK( itk::Object* object ); + virtual void SetVTK( vtkObjectBase* o ); protected: GrowFunction( ); diff --git a/lib/fpaPlugins/GrowFunction.hxx b/lib/fpaPlugins/GrowFunction.hxx index 00c2cba..a8e84b7 100644 --- a/lib/fpaPlugins/GrowFunction.hxx +++ b/lib/fpaPlugins/GrowFunction.hxx @@ -1,26 +1,7 @@ #ifndef __FPAPLUGINS__GROWFUNCTION__HXX__ #define __FPAPLUGINS__GROWFUNCTION__HXX__ -#include - -// ------------------------------------------------------------------------- -template< class F > -void fpaPlugins::GrowFunction:: -SetITK( itk::Object* object ) -{ - typedef typename F::TSpace _TSpace; - typedef typename F::TVertex _TVertex; - typedef itk::FunctionBase< _TVertex, bool > _TBaseFunction; - - _TBaseFunction* function = dynamic_cast< _TBaseFunction* >( object ); - if( function != NULL ) - { - this->m_ITKObject = function; - this->m_VTKObject = NULL; - this->Modified( ); - - } // fi -} +// TODO: erase this file #endif // __FPAPLUGINS__GROWFUNCTION__HXX__ diff --git a/lib/fpaPlugins/ImageDijkstra.cxx b/lib/fpaPlugins/ImageDijkstra.cxx index 185859e..37e16da 100644 --- a/lib/fpaPlugins/ImageDijkstra.cxx +++ b/lib/fpaPlugins/ImageDijkstra.cxx @@ -1,37 +1,17 @@ #include "ImageDijkstra.h" #include -#include #include #include -#include -#include #include -#include -#include - // ------------------------------------------------------------------------- fpaPlugins::ImageDijkstra:: ImageDijkstra( ) : Superclass( ) { - this->_AddInput( "Input" ); - this->_AddInput( "Seeds" ); - this->_AddOutput< cpPlugins::Interface::Image >( "Output" ); this->_AddOutput< fpaPlugins::MinimumSpanningTree >( "MinimumSpanningTree" ); - - this->m_Parameters->ConfigureAsBool( "VisualDebug" ); - this->m_Parameters->ConfigureAsBool( "StopAtOneFront" ); - this->m_Parameters->SetBool( "VisualDebug", false ); - this->m_Parameters->SetBool( "StopAtOneFront", false ); - - std::vector< std::string > orders; - orders.push_back( "1" ); - orders.push_back( "2" ); - this->m_Parameters->ConfigureAsChoices( "NeighborhoodOrder", orders ); - this->m_Parameters->SetSelectedChoice( "NeighborhoodOrder", "1" ); } // ------------------------------------------------------------------------- @@ -46,9 +26,6 @@ _GenerateData( ) { auto input = this->GetInputData< cpPlugins::Interface::Image >( "Input" ); - if( input == NULL ) - return( "fpaPlugins::ImageDijkstra: No input image." ); - itk::DataObject* image = NULL; std::string r = ""; cpPlugins_Image_Demangle_AllScalarTypes( 2, input, image, r, _GD0 ); @@ -67,62 +44,23 @@ _GD0( itk::DataObject* data ) typedef fpa::Image::Dijkstra< I, _TOut > _TFilter; typedef typename _TFilter::TResult _TCost; typedef fpa::Base::Functors::InvertCostFunction< _TCost > _TCostFunctor; - typedef typename I::PointType _TPoint; typedef typename _TFilter::TMinimumSpanningTree _TMST; - auto seeds = - this->GetInputData< cpPlugins::Interface::PointList >( "Seeds" ); - if( seeds == NULL ) - return( "fpaPlugins::ImageRegionGrow: No given seeds." ); - I* image = dynamic_cast< I* >( data ); - - // Create filter and connect input - _TFilter* filter = this->_CreateITK< _TFilter >( ); - filter->SetInput( image ); + // Create filter + _TFilter* filter = this->_ConfigureFilter< _TFilter >( ); // Connect cost functor typename _TCostFunctor::Pointer functor = _TCostFunctor::New( ); filter->SetConversionFunction( functor ); - // Set numeric parameters - Superclass::TParameters* params = this->m_Parameters; - std::string order = params->GetSelectedChoice( "NeighborhoodOrder" ); - filter->SetNeighborhoodOrder( order[ 0 ] - '0' ); - filter->SetStopAtOneFront( params->GetBool( "StopAtOneFront" ) ); - - // Assign seeds - filter->ClearSeeds( ); - for( unsigned int s = 0; s < seeds->GetNumberOfPoints( ); ++s ) - { - _TPoint pnt = seeds->GetPoint< _TPoint >( s ); - typename I::IndexType idx; - if( image->TransformPhysicalPointToIndex( pnt, idx ) ) - filter->AddSeed( idx, 0 ); - - } // rof - // Go!!! - this->_ConfigureDebugger( filter ); - filter->Update( ); - this->_DeconfigureDebugger( filter ); + this->_ExecuteFilter( filter ); - // Connect output - auto out = - this->GetOutputData< cpPlugins::Interface::Image >( "Output" ); + // Connect remaining output auto mst = this->GetOutputData< fpaPlugins::MinimumSpanningTree >( "MinimumSpanningTree" ); - if( out != NULL ) - out->SetITK< _TOut >( filter->GetOutput( ) ); - else - return( "fpaPlugins::ImageDijkstra: output not correctly created." ); - - if( mst != NULL ) - { - mst->SetITK< _TMST >( filter->GetMinimumSpanningTree( ) ); - return( "" ); - } - else - return( "fpaPlugins::ImageDijkstra: minimum spanning tree." ); + mst->SetITK( filter->GetMinimumSpanningTree( ) ); + return( "" ); } // eof - $RCSfile$ diff --git a/lib/fpaPlugins/ImageRegionGrow.cxx b/lib/fpaPlugins/ImageRegionGrow.cxx index 19eba80..07697ce 100644 --- a/lib/fpaPlugins/ImageRegionGrow.cxx +++ b/lib/fpaPlugins/ImageRegionGrow.cxx @@ -1,41 +1,22 @@ #include "ImageRegionGrow.h" #include -#include - #include - #include #include -#include -#include - // ------------------------------------------------------------------------- fpaPlugins::ImageRegionGrow:: ImageRegionGrow( ) : Superclass( ) { - this->_AddInput( "Input" ); - this->_AddInput( "GrowFunction" ); - this->_AddInput( "Seeds" ); - this->_AddOutput< cpPlugins::Interface::Image >( "Output" ); + this->_AddInput( "GrowFunction", false ); - this->m_Parameters->ConfigureAsBool( "VisualDebug" ); - this->m_Parameters->ConfigureAsBool( "StopAtOneFront" ); this->m_Parameters->ConfigureAsReal( "InsideValue" ); this->m_Parameters->ConfigureAsReal( "OutsideValue" ); - this->m_Parameters->SetBool( "VisualDebug", false ); - this->m_Parameters->SetBool( "StopAtOneFront", false ); this->m_Parameters->SetReal( "InsideValue", 1 ); this->m_Parameters->SetReal( "OutsideValue", 0 ); - - std::vector< std::string > orders; - orders.push_back( "1" ); - orders.push_back( "2" ); - this->m_Parameters->ConfigureAsChoices( "NeighborhoodOrder", orders ); - this->m_Parameters->SetSelectedChoice( "NeighborhoodOrder", "1" ); } // ------------------------------------------------------------------------- @@ -50,9 +31,6 @@ _GenerateData( ) { auto input = this->GetInputData< cpPlugins::Interface::Image >( "Input" ); - if( input == NULL ) - return( "fpaPlugins::ImageRegionGrow: No input image." ); - itk::DataObject* image = NULL; std::string r = ""; cpPlugins_Image_Demangle_AllScalarTypes( 2, input, image, r, _GD0 ); @@ -70,17 +48,9 @@ _GD0( itk::DataObject* data ) typedef itk::Image< _TOutPixel, I::ImageDimension > _TOut; typedef fpa::Image::RegionGrow< I, _TOut > _TFilter; typedef typename _TFilter::TGrowingFunction _TFunctor; - typedef typename I::PointType _TPoint; - auto seeds = - this->GetInputData< cpPlugins::Interface::PointList >( "Seeds" ); - if( seeds == NULL ) - return( "fpaPlugins::ImageRegionGrow: No given seeds." ); - I* image = dynamic_cast< I* >( data ); - - // Create filter and connect input - _TFilter* filter = this->_CreateITK< _TFilter >( ); - filter->SetInput( image ); + // Create filter + _TFilter* filter = this->_ConfigureFilter< _TFilter >( ); // Connect grow functor (or create a tautology) typename _TFunctor::Pointer functor; @@ -94,39 +64,16 @@ _GD0( itk::DataObject* data ) filter->SetGrowingFunction( functor ); // Set numeric parameters - Superclass::TParameters* params = this->m_Parameters; - std::string order = params->GetSelectedChoice( "NeighborhoodOrder" ); - filter->SetNeighborhoodOrder( order[ 0 ] - '0' ); - filter->SetStopAtOneFront( params->GetBool( "StopAtOneFront" ) ); - filter->SetInsideValue( _TOutPixel( params->GetReal( "InsideValue" ) ) ); - filter->SetOutsideValue( _TOutPixel( params->GetReal( "OutsideValue" ) ) ); - - // Assign seeds - filter->ClearSeeds( ); - for( unsigned int s = 0; s < seeds->GetNumberOfPoints( ); ++s ) - { - _TPoint pnt = seeds->GetPoint< _TPoint >( s ); - typename I::IndexType idx; - if( image->TransformPhysicalPointToIndex( pnt, idx ) ) - filter->AddSeed( idx, 0 ); - - } // rof + filter->SetInsideValue( + _TOutPixel( this->m_Parameters->GetReal( "InsideValue" ) ) + ); + filter->SetOutsideValue( + _TOutPixel( this->m_Parameters->GetReal( "OutsideValue" ) ) + ); // Go!!! - this->_ConfigureDebugger( filter ); - filter->Update( ); - this->_DeconfigureDebugger( filter ); - - // Connect output - auto out = - this->GetOutputData< cpPlugins::Interface::Image >( "Output" ); - if( out != NULL ) - { - out->SetITK< _TOut >( filter->GetOutput( ) ); - return( "" ); - } - else - return( "fpaPlugins::ImageRegionGrow: output not correctly created." ); + this->_ExecuteFilter( filter ); + return( "" ); } // eof - $RCSfile$ diff --git a/lib/fpaPlugins/MinimumSpanningTree.cxx b/lib/fpaPlugins/MinimumSpanningTree.cxx index 7803f8d..ad561e8 100644 --- a/lib/fpaPlugins/MinimumSpanningTree.cxx +++ b/lib/fpaPlugins/MinimumSpanningTree.cxx @@ -1,5 +1,12 @@ #include +// ------------------------------------------------------------------------- +void fpaPlugins::MinimumSpanningTree:: +SetVTK( vtkObjectBase* o ) +{ + // Do nothing: this only has sense in ITK +} + // ------------------------------------------------------------------------- fpaPlugins::MinimumSpanningTree:: MinimumSpanningTree( ) diff --git a/lib/fpaPlugins/MinimumSpanningTree.h b/lib/fpaPlugins/MinimumSpanningTree.h index b09a0f8..557583c 100644 --- a/lib/fpaPlugins/MinimumSpanningTree.h +++ b/lib/fpaPlugins/MinimumSpanningTree.h @@ -26,8 +26,7 @@ namespace fpaPlugins cpPlugins_Id_Macro( MinimumSpanningTree, MinimumSpanningTree ); public: - template< class M > - inline void SetITK( itk::Object* object ); + void SetVTK( vtkObjectBase* o ); protected: MinimumSpanningTree( ); diff --git a/lib/fpaPlugins/MinimumSpanningTree.hxx b/lib/fpaPlugins/MinimumSpanningTree.hxx index 34cf61f..ccbda26 100644 --- a/lib/fpaPlugins/MinimumSpanningTree.hxx +++ b/lib/fpaPlugins/MinimumSpanningTree.hxx @@ -1,20 +1,7 @@ #ifndef __FPAPLUGINS__MINIMUMSPANNINGTREE__HXX__ #define __FPAPLUGINS__MINIMUMSPANNINGTREE__HXX__ -// ------------------------------------------------------------------------- -template< class M > -void fpaPlugins::MinimumSpanningTree:: -SetITK( itk::Object* object ) -{ - M* tree = dynamic_cast< M* >( object ); - if( tree != NULL ) - { - this->m_ITKObject = tree; - this->m_VTKObject = NULL; - this->Modified( ); - - } // fi -} +// TODO: delete this file #endif // __FPAPLUGINS__MINIMUMSPANNINGTREE__HXX__ diff --git a/lib/fpaPlugins/MinimumSpanningTreeToMesh.cxx b/lib/fpaPlugins/MinimumSpanningTreeToMesh.cxx index 36d61c2..c474429 100644 --- a/lib/fpaPlugins/MinimumSpanningTreeToMesh.cxx +++ b/lib/fpaPlugins/MinimumSpanningTreeToMesh.cxx @@ -39,10 +39,6 @@ _GenerateData( ) auto input = this->GetInputData< cpPlugins::Interface::Image >( "ReferenceImage" ); - - if( input == NULL ) - return( "fpaPlugins::MinimumSpanningTreeToMesh: No reference image." ); - _2D* im2d = input->GetITK< _2D >( ); _3D* im3d = input->GetITK< _3D >( ); if( im2d != NULL ) @@ -66,15 +62,11 @@ _GD0( I* image ) // Get inputs auto mst_wrapper = this->GetInputData< fpaPlugins::MinimumSpanningTree >( "Input" ); - if( mst_wrapper == NULL ) - return( "fpaPlugins::MinimumSpanningTreeToMesh: No input MST" ); _MST* mst = mst_wrapper->GetITK< _MST >( ); if( mst == NULL ) return( "fpaPlugins::MinimumSpanningTreeToMesh: Input MST type not supported." ); auto seeds = this->GetInputData< cpPlugins::Interface::PointList >( "Seeds" ); - if( seeds == NULL ) - return( "fpaPlugins::MinimumSpanningTreeToMesh: No given seeds." ); if( seeds->GetNumberOfPoints( ) < 2 ) return( "fpaPlugins::MinimumSpanningTreeToMesh: Not enough seeds (<2)." ); diff --git a/lib/fpaPlugins/ThresholdImageGrowFunctionSource.cxx b/lib/fpaPlugins/ThresholdImageGrowFunctionSource.cxx index eabd396..4863f4d 100644 --- a/lib/fpaPlugins/ThresholdImageGrowFunctionSource.cxx +++ b/lib/fpaPlugins/ThresholdImageGrowFunctionSource.cxx @@ -32,9 +32,6 @@ _GenerateData( ) { auto image = this->GetInputData< cpPlugins::Interface::Image >( "ReferenceImage" ); - if( image == NULL ) - return( "fpaPlugins::ThresholdImageGrowFunctionSource: No input reference image." ); - itk::DataObject* itk_image = NULL; std::string r = ""; cpPlugins_Image_Demangle_AllScalarTypes( 2, image, itk_image, r, _GD0 ); @@ -50,19 +47,19 @@ std::string fpaPlugins::ThresholdImageGrowFunctionSource:: _GD0( itk::DataObject* data ) { typedef fpa::Image::Functors::RegionGrowThresholdFunction< I > _F; - typename _F::Pointer f = _F::New( ); - f->SetLowerThreshold( this->m_Parameters->GetReal( "LowerThreshold" ) ); - f->SetUpperThreshold( this->m_Parameters->GetReal( "UpperThreshold" ) ); - // Connect output auto out = this->GetOutputData< GrowFunction >( "Output" ); - if( out != NULL ) + auto f = out->GetITK< _F >( ); + if( f == NULL ) { - out->SetITK< _F >( f ); - return( "" ); - } - else - return( "fpaPlugins::ThresholdImageGrowFunctionSource: output not correctly created." ); + typename _F::Pointer ptr_f = _F::New( ); + f = ptr_f.GetPointer( ); + out->SetITK( f ); + + } // fi + f->SetLowerThreshold( this->m_Parameters->GetReal( "LowerThreshold" ) ); + f->SetUpperThreshold( this->m_Parameters->GetReal( "UpperThreshold" ) ); + return( "" ); } // eof - $RCSfile$ -- 2.47.1