]> Creatis software - cpPlugins.git/blobdiff - lib/cpExtensions/Algorithms/CPRFilter.hxx
Some bugs on CPR solved.
[cpPlugins.git] / lib / cpExtensions / Algorithms / CPRFilter.hxx
index 3b19a9fe6305db89b6fd093db1774885a748826c..4a2169ed8f9aa182dd95022e5811a13797b1499a 100644 (file)
@@ -7,7 +7,7 @@
 
 #include <itkPoint.h>
 #include <itkMinimumMaximumImageCalculator.h>
-#include <itkNearestNeighborInterpolateImageFunction.h>
+#include <itkLinearInterpolateImageFunction.h>
 #include <cpExtensions/Algorithms/BezierCurveFunction.h>
 
 // -------------------------------------------------------------------------
@@ -16,6 +16,9 @@ const typename cpExtensions::Algorithms::CPRFilter< I, S >::
 TAxis* cpExtensions::Algorithms::CPRFilter< I, S >::
 GetAxis( ) const
 {
+  return(
+    dynamic_cast< const TAxis* >( this->itk::ProcessObject::GetInput( 1 ) )
+    );
 }
 
 // -------------------------------------------------------------------------
@@ -23,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 ) );
 }
 
 // -------------------------------------------------------------------------
@@ -32,7 +36,7 @@ CPRFilter( )
   : Superclass( )
 {
   this->m_Interpolator =
-    itk::NearestNeighborInterpolateImageFunction< I, S >::New( );
+    itk::LinearInterpolateImageFunction< I, S >::New( );
 }
 
 // -------------------------------------------------------------------------
@@ -42,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 >::
@@ -86,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 )
@@ -105,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( ) );
@@ -118,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( ) );
 }