From 8ebfdf11e4b5d2a5b3a0c2b4752d176888f0bb16 Mon Sep 17 00:00:00 2001 From: Leonardo Florez-Valencia Date: Tue, 16 Feb 2016 15:37:43 -0500 Subject: [PATCH] Some bugs on CPR solved. --- lib/cpExtensions/Algorithms/CPRFilter.h | 2 +- lib/cpExtensions/Algorithms/CPRFilter.hxx | 24 +++++++++++++++---- .../Algorithms/IsoImageSlicer.hxx | 1 + lib/cpPlugins/Interface/ProcessObject.cxx | 3 +-- lib/cpPlugins/Interface/ProcessObjectPort.cxx | 3 ++- 5 files changed, 25 insertions(+), 8 deletions(-) diff --git a/lib/cpExtensions/Algorithms/CPRFilter.h b/lib/cpExtensions/Algorithms/CPRFilter.h index 43bd0fa..4a4e660 100644 --- a/lib/cpExtensions/Algorithms/CPRFilter.h +++ b/lib/cpExtensions/Algorithms/CPRFilter.h @@ -60,7 +60,7 @@ namespace cpExtensions CPRFilter( ); virtual ~CPRFilter( ); - private: + virtual void GenerateOutputInformation( ); virtual void GenerateData( ); protected: diff --git a/lib/cpExtensions/Algorithms/CPRFilter.hxx b/lib/cpExtensions/Algorithms/CPRFilter.hxx index 5db673d..4a2169e 100644 --- a/lib/cpExtensions/Algorithms/CPRFilter.hxx +++ b/lib/cpExtensions/Algorithms/CPRFilter.hxx @@ -7,7 +7,7 @@ #include #include -#include +#include #include // ------------------------------------------------------------------------- @@ -16,7 +16,9 @@ const typename cpExtensions::Algorithms::CPRFilter< I, S >:: TAxis* cpExtensions::Algorithms::CPRFilter< I, S >:: GetAxis( ) const { - return( NULL ); + return( + dynamic_cast< const TAxis* >( this->itk::ProcessObject::GetInput( 1 ) ) + ); } // ------------------------------------------------------------------------- @@ -24,6 +26,7 @@ template< class I, class S > void cpExtensions::Algorithms::CPRFilter< I, S >:: SetAxis( const TAxis* axis ) { + this->itk::ProcessObject::SetNthInput( 1, const_cast< TAxis* >( axis ) ); } // ------------------------------------------------------------------------- @@ -33,7 +36,7 @@ CPRFilter( ) : Superclass( ) { this->m_Interpolator = - itk::NearestNeighborInterpolateImageFunction< I, S >::New( ); + itk::LinearInterpolateImageFunction< I, S >::New( ); } // ------------------------------------------------------------------------- @@ -43,6 +46,14 @@ cpExtensions::Algorithms::CPRFilter< I, S >:: { } +// ------------------------------------------------------------------------- +template< class I, class S > +void cpExtensions::Algorithms::CPRFilter< I, S >:: +GenerateOutputInformation( ) +{ + // Do nothing since the output has different geometry and topology. +} + // ------------------------------------------------------------------------- template< class I, class S > void cpExtensions::Algorithms::CPRFilter< I, S >:: @@ -87,6 +98,7 @@ GenerateData( ) { // Get geometrical data and correct Frenet frame S u = S( i ) / S( nSlices ); + std::cout << u << std::endl; _V vnex = bezier->Evaluate( u ); _M mnex = bezier->EvaluateFrenetFrame( u ); if( i > 0 ) @@ -106,6 +118,9 @@ GenerateData( ) slicer->SpacingFromMinimumOn( ); slicer->SetDefaultValue( background ); slicer->SetInterpolator( this->m_Interpolator ); + slicer->Update( ); + + std::cout << slicer->GetOutput( )->GetLargestPossibleRegion( ).GetSize( ) << std::endl; // Add output to join filter and keep track of the current slicer this->m_Join->SetInput( i, slicer->GetOutput( ) ); @@ -119,11 +134,12 @@ GenerateData( ) // 3. Finish join filter configuration this->m_Join->SetSpacing( double( len / S( nSlices + 1 ) ) ); + std::cout << this->m_Join->GetSpacing( ) << std::endl; this->m_Join->SetOrigin( double( 0 ) ); // 4. Graft outputs this->m_Join->GraftOutput( this->GetOutput( ) ); - this->m_Join->UpdateLargestPossibleRegion( ); + this->m_Join->Update( );//LargestPossibleRegion( ); this->GraftOutput( this->m_Join->GetOutput( ) ); } diff --git a/lib/cpExtensions/Algorithms/IsoImageSlicer.hxx b/lib/cpExtensions/Algorithms/IsoImageSlicer.hxx index ff72c1a..041d874 100644 --- a/lib/cpExtensions/Algorithms/IsoImageSlicer.hxx +++ b/lib/cpExtensions/Algorithms/IsoImageSlicer.hxx @@ -116,6 +116,7 @@ BaseImageSlicer( ) // Dimension collapsor this->m_Collapsor = TCollapsor::New( ); this->m_Collapsor->SetInput( this->m_Slicer->GetOutput( ) ); + this->m_Collapsor->SetDirectionCollapseToIdentity( ); this->m_Transform = TTransform::New( ); this->m_Transform->SetIdentity( ); diff --git a/lib/cpPlugins/Interface/ProcessObject.cxx b/lib/cpPlugins/Interface/ProcessObject.cxx index 72897d6..5bafb80 100644 --- a/lib/cpPlugins/Interface/ProcessObject.cxx +++ b/lib/cpPlugins/Interface/ProcessObject.cxx @@ -226,8 +226,7 @@ _AddInput( const std::string& name, bool required ) auto i = this->m_Inputs.find( name ); if( i == this->m_Inputs.end( ) ) { - InputProcessObjectPort new_port( required ); - this->m_Inputs[ name ] = new_port; + this->m_Inputs[ name ] = InputProcessObjectPort( required ); this->Modified( ); } // fi diff --git a/lib/cpPlugins/Interface/ProcessObjectPort.cxx b/lib/cpPlugins/Interface/ProcessObjectPort.cxx index d7bbcf4..1174d2b 100644 --- a/lib/cpPlugins/Interface/ProcessObjectPort.cxx +++ b/lib/cpPlugins/Interface/ProcessObjectPort.cxx @@ -41,7 +41,8 @@ IsValid( ) const // ------------------------------------------------------------------------- cpPlugins::Interface::InputProcessObjectPort:: InputProcessObjectPort( bool required ) - : Superclass( ) + : Superclass( ), + m_Required( required ) { } -- 2.49.0