From 14b462901dbf2cfeded8fa762235e3d47ec2030b Mon Sep 17 00:00:00 2001 From: Leonardo Florez-Valencia Date: Fri, 22 Apr 2016 18:03:11 -0500 Subject: [PATCH] ... --- plugins/fpa/BaseImageFilter.hxx | 35 ++++++++++++------- ...AndBifurcationsFromMinimumSpanningTree.cxx | 14 ++++---- .../ExtractPathFromMinimumSpanningTree.cxx | 29 ++++++++++----- .../fpa/GradientBaseImageFunctionSource.cxx | 4 +-- plugins/fpa/ImageDijkstra.cxx | 10 +++--- plugins/fpa/ImageDijkstra.h | 8 +++++ plugins/fpa/ImageRegionGrow.cxx | 7 ++-- plugins/fpa/InvertCostFunction.cxx | 2 +- plugins/fpa/MinimumSpanningTreeReader.cxx | 2 +- plugins/fpa/MinimumSpanningTreeWriter.cxx | 4 +-- plugins/fpa/RegionGrowThresholdFunction.cxx | 5 ++- 11 files changed, 73 insertions(+), 47 deletions(-) diff --git a/plugins/fpa/BaseImageFilter.hxx b/plugins/fpa/BaseImageFilter.hxx index 6bce1d5..b8e0269 100644 --- a/plugins/fpa/BaseImageFilter.hxx +++ b/plugins/fpa/BaseImageFilter.hxx @@ -11,14 +11,11 @@ _ConfigureFilter( ) { typedef typename _TFilter::TInputImage _TImage; static const unsigned int Dim = _TImage::ImageDimension; - typedef - cpExtensions::DataStructures::ImageIndexesContainer< Dim > - _TIndexes; - auto image = this->GetInputData( "Input" )->GetITK< _TImage >( ); + auto image = this->GetInputData< _TImage >( "Input" ); if( image == NULL ) return( NULL ); - auto indexes = this->GetInputData( "Seeds" )->GetITK< _TIndexes >( ); + auto seeds = this->GetInputData< vtkPoints >( "Seeds" ); // Create filter and connect input auto filter = this->_CreateITK< _TFilter >( ); @@ -32,11 +29,24 @@ _ConfigureFilter( ) // Assign seeds filter->ClearSeeds( ); - if( indexes != NULL ) + if( seeds != NULL ) { - auto iIt = indexes->Get( ).begin( ); - for( ; iIt != indexes->Get( ).end( ); ++iIt ) - filter->AddSeed( *iIt, 0 ); + typename _TImage::PointType pnt; + typename _TImage::IndexType idx; + unsigned int dim = + ( _TImage::ImageDimension < 3 )? _TImage::ImageDimension: 3; + for( unsigned int i = 0; i < seeds->GetNumberOfPoints( ); ++i ) + { + double buf[ 3 ]; + seeds->GetPoint( i, buf ); + pnt.Fill( 0 ); + for( unsigned int d = 0; d < dim; ++d ) + pnt[ d ] = buf[ d ]; + + if( image->TransformPhysicalPointToIndex( pnt, idx ) ) + filter->AddSeed( idx, 0 ); + + } // rof } // fi @@ -50,13 +60,12 @@ void fpaPlugins::BaseImageFilter:: _ExecuteFilter( _TFilter* filter ) { // Go!!! - this->_ConfigureDebugger( filter ); + // this->_ConfigureDebugger( filter ); filter->Update( ); - this->_DeconfigureDebugger( filter ); + // this->_DeconfigureDebugger( filter ); // Connect output - auto out = this->GetOutputData( "Output" ); - out->SetITK( filter->GetOutput( ) ); + this->GetOutput( "Output" )->SetITK( filter->GetOutput( ) ); } // ------------------------------------------------------------------------- diff --git a/plugins/fpa/ExtractEndPointsAndBifurcationsFromMinimumSpanningTree.cxx b/plugins/fpa/ExtractEndPointsAndBifurcationsFromMinimumSpanningTree.cxx index 73fbad0..ea2c37a 100644 --- a/plugins/fpa/ExtractEndPointsAndBifurcationsFromMinimumSpanningTree.cxx +++ b/plugins/fpa/ExtractEndPointsAndBifurcationsFromMinimumSpanningTree.cxx @@ -32,7 +32,7 @@ fpaPlugins::ExtractEndPointsAndBifurcationsFromMinimumSpanningTree:: void fpaPlugins::ExtractEndPointsAndBifurcationsFromMinimumSpanningTree:: _GenerateData( ) { - auto image = this->GetInputData( "CostsImage" )->GetITK< itk::DataObject >( ); + auto image = this->GetInputData< itk::DataObject >( "CostsImage" ); cpPlugins_Image_Demangle_Pixel_AllFloats ( _GD0, image, 2 ); else cpPlugins_Image_Demangle_Pixel_AllFloats( _GD0, image, 3 ); else this->_Error( "Invalid input costs." ); @@ -47,10 +47,10 @@ _GD0( _TImage* image ) typedef fpa::Image::ExtractEndPointsAndBifurcationsFromMinimumSpanningTree< _TImage, _TMST > _TFilter; // Check input objects' integrity - auto dmap = this->GetInputData( "DistanceMap" )->GetITK< _TImage >( ); + auto dmap = this->GetInputData< _TImage >( "DistanceMap" ); if( dmap == NULL ) this->_Error( "Distance map does not have the same type as the costs image." ); - auto mst = this->GetInputData( "MST" )->GetITK< _TMST >( ); + auto mst = this->GetInputData< _TMST >( "MST" ); if( mst == NULL ) this->_Error( "No valid input tree." ); @@ -64,10 +64,10 @@ _GD0( _TImage* image ) ); filter->Update( ); - this->GetOutputData( "EndPoints" )->SetITK( filter->GetEndPoints( ) ); - this->GetOutputData( "Bifurcations" )->SetITK( filter->GetBifurcations( ) ); - this->GetOutputData( "Collisions" )->SetITK( filter->GetCollisions( ) ); - this->GetOutputData( "Skeleton" )->SetITK( filter->GetSkeleton( ) ); + this->GetOutput( "EndPoints" )->SetITK( filter->GetEndPoints( ) ); + this->GetOutput( "Bifurcations" )->SetITK( filter->GetBifurcations( ) ); + this->GetOutput( "Collisions" )->SetITK( filter->GetCollisions( ) ); + this->GetOutput( "Skeleton" )->SetITK( filter->GetSkeleton( ) ); } // eof - $RCSfile$ diff --git a/plugins/fpa/ExtractPathFromMinimumSpanningTree.cxx b/plugins/fpa/ExtractPathFromMinimumSpanningTree.cxx index 7e41b4f..0f717ab 100644 --- a/plugins/fpa/ExtractPathFromMinimumSpanningTree.cxx +++ b/plugins/fpa/ExtractPathFromMinimumSpanningTree.cxx @@ -31,7 +31,7 @@ _GenerateData( ) typedef fpa::Image::MinimumSpanningTree< 2 > _2DMST; typedef fpa::Image::MinimumSpanningTree< 3 > _3DMST; - auto mst = this->GetInputData( "MST" )->GetITK< itk::DataObject >( ); + auto mst = this->GetInputData< itk::DataObject >( "MST" ); auto mst2 = dynamic_cast< _2DMST* >( mst ); auto mst3 = dynamic_cast< _3DMST* >( mst ); if ( mst2 != NULL ) this->_GD0( mst2 ); @@ -45,16 +45,27 @@ void fpaPlugins::ExtractPathFromMinimumSpanningTree:: _GD0( _TMST* mst ) { typedef fpa::Base::ExtractPathFromMinimumSpanningTree< _TMST > _TFilter; - typedef - cpExtensions::DataStructures::ImageIndexesContainer< _TMST::Dimension > - _TVertices; - auto vertices = this->GetInputData( "Seeds" )->GetITK< _TVertices >( ); + auto vertices = this->GetInputData< vtkPoints >( "Seeds" ); if( vertices == NULL ) this->_Error( "No valid vertices." ); - if( vertices->Get( ).size( ) < 2 ) + if( vertices->GetNumberOfPoints( ) < 2 ) this->_Error( "Not enough vertices." ); - auto v0 = vertices->Get( )[ this->m_Parameters.GetUint( "Vertex0" ) ]; - auto v1 = vertices->Get( )[ this->m_Parameters.GetUint( "Vertex1" ) ]; + + double b0[ 3 ], b1[ 3 ]; + vertices->GetPoint( this->m_Parameters.GetUint( "Vertex0" ), b0 ); + vertices->GetPoint( this->m_Parameters.GetUint( "Vertex1" ), b1 ); + + typename _TMST::PointType p0, p1; + unsigned int dim = ( _TMST::ImageDimension < 3 )? _TMST::ImageDimension: 3; + for( unsigned int d = 0; d < dim; ++d ) + { + p0[ d ] = b0[ d ]; + p1[ d ] = b1[ d ]; + + } // rof + typename _TMST::TVertex v0, v1; + mst->TransformPhysicalPointToIndex( p0, v0 ); + mst->TransformPhysicalPointToIndex( p1, v1 ); // Create filter and connect input _TFilter* filter = this->_CreateITK< _TFilter >( ); @@ -64,7 +75,7 @@ _GD0( _TMST* mst ) filter->Update( ); // Connect output and finish - this->GetOutputData( "Output" )->SetITK( filter->GetOutput( ) ); + this->GetOutput( "Output" )->SetITK( filter->GetOutput( ) ); } // eof - $RCSfile$ diff --git a/plugins/fpa/GradientBaseImageFunctionSource.cxx b/plugins/fpa/GradientBaseImageFunctionSource.cxx index df069d3..85a79ce 100644 --- a/plugins/fpa/GradientBaseImageFunctionSource.cxx +++ b/plugins/fpa/GradientBaseImageFunctionSource.cxx @@ -38,7 +38,7 @@ fpaPlugins::GradientBaseImageFunctionSource:: void fpaPlugins::GradientBaseImageFunctionSource:: _GenerateData( ) { - auto image = this->GetInputData( "Input" )->GetITK< itk::DataObject >( ); + auto image = this->GetInputData< itk::DataObject >( "Input" ); cpPlugins_Image_Demangle_VectorPixel_AllFloats ( _GD0, image, CovariantVector, 2 ); else cpPlugins_Image_Demangle_VectorPixel_AllFloats( _GD0, image, CovariantVector, 3 ); else this->_Error( "Invalid input image." ); @@ -87,7 +87,7 @@ _GD1( _TImage* image ) filter->Update( ); // Connect output and finish - this->GetOutputData( "Output" )->SetITK( filter->GetOutput( ) ); + this->GetOutput( "Output" )->SetITK( filter->GetOutput( ) ); } // eof - $RCSfile$ diff --git a/plugins/fpa/ImageDijkstra.cxx b/plugins/fpa/ImageDijkstra.cxx index b45999d..d2fae9a 100644 --- a/plugins/fpa/ImageDijkstra.cxx +++ b/plugins/fpa/ImageDijkstra.cxx @@ -25,7 +25,7 @@ fpaPlugins::ImageDijkstra:: void fpaPlugins::ImageDijkstra:: _GenerateData( ) { - auto image = this->GetInputData( "Input" )->GetITK< itk::DataObject >( ); + auto image = this->GetInputData< itk::DataObject >( "Input" ); cpPlugins_Image_Demangle_Pixel_AllScalars ( _GD0, image, 2 ); else cpPlugins_Image_Demangle_Pixel_AllScalars( _GD0, image, 3 ); else this->_Error( "No valid input image." ); @@ -44,7 +44,7 @@ _GD0( _TImage* image ) typedef typename _TFilter::TMinimumSpanningTree _TMST; auto base_functor = - this->GetInputData( "CostFunctor" )->GetITK< itk::LightObject >( ); + this->GetInputData< itk::LightObject >( "CostFunctor" ); _TCostFunctor* functor = NULL; if( base_functor != NULL ) { @@ -63,8 +63,10 @@ _GD0( _TImage* image ) this->_ExecuteFilter( filter ); // Connect remaining output - this->GetOutputData( "Output" )->SetITK( filter->GetOutput( ) ); - this->GetOutputData( "MST" )->SetITK( filter->GetMinimumSpanningTree( ) ); + this->GetOutput( "MST" )->SetITK( filter->GetMinimumSpanningTree( ) ); + + std::cout << "Internal: " << filter->GetMTime( ) << std::endl; + } // eof - $RCSfile$ diff --git a/plugins/fpa/ImageDijkstra.h b/plugins/fpa/ImageDijkstra.h index e4cb3de..efc86fb 100644 --- a/plugins/fpa/ImageDijkstra.h +++ b/plugins/fpa/ImageDijkstra.h @@ -21,6 +21,14 @@ namespace fpaPlugins itkTypeMacro( ImageDijkstra, BaseImageFilter ); cpPlugins_Id_Macro( ImageDijkstra, fpaImageAlgorithm ); + virtual itk::ModifiedTimeType GetMTime( ) const + { + auto t = this->Superclass::GetMTime( ); + std::cout << "Dijkstra time: " << t << std::endl; + return( t ); + } + + protected: ImageDijkstra( ); virtual ~ImageDijkstra( ); diff --git a/plugins/fpa/ImageRegionGrow.cxx b/plugins/fpa/ImageRegionGrow.cxx index 16a47e8..333c708 100644 --- a/plugins/fpa/ImageRegionGrow.cxx +++ b/plugins/fpa/ImageRegionGrow.cxx @@ -25,7 +25,7 @@ fpaPlugins::ImageRegionGrow:: void fpaPlugins::ImageRegionGrow:: _GenerateData( ) { - auto image = this->GetInputData( "Input" )->GetITK< itk::DataObject >( ); + auto image = this->GetInputData< itk::DataObject >( "Input" ); cpPlugins_Image_Demangle_Pixel_AllScalars ( _GD0, image, 2 ); else cpPlugins_Image_Demangle_Pixel_AllScalars( _GD0, image, 3 ); else this->_Error( "No valid input image." ); @@ -46,7 +46,7 @@ _GD0( _TImage* image ) _TFilter* filter = this->_ConfigureFilter< _TFilter >( ); typename _TGrowFunctor::Pointer functor; - auto wrap_functor = this->GetInputData( "GrowFunctor" ); + auto wrap_functor = this->GetInput( "GrowFunctor" ); if( wrap_functor != NULL ) functor = wrap_functor->GetITK< _TGrowFunctor >( ); if( functor.IsNull( ) ) @@ -60,9 +60,6 @@ _GD0( _TImage* image ) // Go!!! this->_ExecuteFilter( filter ); - - // Connect remaining output - this->GetOutputData( "Output" )->SetITK( filter->GetOutput( ) ); } // eof - $RCSfile$ diff --git a/plugins/fpa/InvertCostFunction.cxx b/plugins/fpa/InvertCostFunction.cxx index abd4f1e..3664bfa 100644 --- a/plugins/fpa/InvertCostFunction.cxx +++ b/plugins/fpa/InvertCostFunction.cxx @@ -45,7 +45,7 @@ void fpaPlugins::InvertCostFunction:: _GD0( ) { typedef fpa::Base::Functors::InvertCostFunction< _TScalar > _TFunctor; - auto out = this->GetOutputData( "Output" ); + auto out = this->GetOutput( "Output" ); auto f = out->GetITK< _TFunctor >( ); if( f == NULL ) { diff --git a/plugins/fpa/MinimumSpanningTreeReader.cxx b/plugins/fpa/MinimumSpanningTreeReader.cxx index 16f421e..e0c4ffe 100644 --- a/plugins/fpa/MinimumSpanningTreeReader.cxx +++ b/plugins/fpa/MinimumSpanningTreeReader.cxx @@ -64,7 +64,7 @@ _GD0( const std::string& fname ) this->_Error( err.GetDescription( ) ); } // yrt - this->GetOutputData( "Output" )->SetITK( reader->GetOutput( ) ); + this->GetOutput( "Output" )->SetITK( reader->GetOutput( ) ); } // eof - $RCSfile$ diff --git a/plugins/fpa/MinimumSpanningTreeWriter.cxx b/plugins/fpa/MinimumSpanningTreeWriter.cxx index d0f3559..9910908 100644 --- a/plugins/fpa/MinimumSpanningTreeWriter.cxx +++ b/plugins/fpa/MinimumSpanningTreeWriter.cxx @@ -30,8 +30,8 @@ _GenerateData( ) typedef fpa::Image::MinimumSpanningTree< 2 > _2D; typedef fpa::Image::MinimumSpanningTree< 3 > _3D; - auto _2d = this->GetInputData( "Input" )->GetITK< _2D >( ); - auto _3d = this->GetInputData( "Input" )->GetITK< _3D >( ); + auto _2d = this->GetInputData< _2D >( "Input" ); + auto _3d = this->GetInputData< _3D >( "Input" ); if ( _2d != NULL ) this->_GD0( _2d ); else if( _3d != NULL ) this->_GD0( _3d ); diff --git a/plugins/fpa/RegionGrowThresholdFunction.cxx b/plugins/fpa/RegionGrowThresholdFunction.cxx index 8dc341f..4e8ca64 100644 --- a/plugins/fpa/RegionGrowThresholdFunction.cxx +++ b/plugins/fpa/RegionGrowThresholdFunction.cxx @@ -28,8 +28,7 @@ fpaPlugins::RegionGrowThresholdFunction:: void fpaPlugins::RegionGrowThresholdFunction:: _GenerateData( ) { - auto image = - this->GetInputData( "ReferenceImage" )->GetITK< itk::DataObject >( ); + auto image = this->GetInputData< itk::DataObject >( "ReferenceImage" ); cpPlugins_Image_Demangle_Pixel_AllScalars ( _GD0, image, 2 ); else cpPlugins_Image_Demangle_Pixel_AllScalars( _GD0, image, 3 ); else this->_Error( "No valid input image." ); @@ -44,7 +43,7 @@ _GD0( _TImage* image ) fpa::Image::Functors::RegionGrowThresholdFunction< _TImage > _TFunctor; - auto out = this->GetOutputData( "Output" ); + auto out = this->GetOutput( "Output" ); auto f = out->GetITK< _TFunctor >( ); if( f == NULL ) { -- 2.45.1