]> Creatis software - cpPlugins.git/commitdiff
Some bugs on CPR solved.
authorLeonardo Florez-Valencia <florez-l@javeriana.edu.co>
Tue, 16 Feb 2016 20:37:43 +0000 (15:37 -0500)
committerLeonardo Florez-Valencia <florez-l@javeriana.edu.co>
Tue, 16 Feb 2016 20:37:43 +0000 (15:37 -0500)
lib/cpExtensions/Algorithms/CPRFilter.h
lib/cpExtensions/Algorithms/CPRFilter.hxx
lib/cpExtensions/Algorithms/IsoImageSlicer.hxx
lib/cpPlugins/Interface/ProcessObject.cxx
lib/cpPlugins/Interface/ProcessObjectPort.cxx

index 43bd0fa80999d102cf3ca061ee57b79cba8c406f..4a4e660e6a45fdaeef6e2f0a7cbcd5dce436da44 100644 (file)
@@ -60,7 +60,7 @@ namespace cpExtensions
       CPRFilter( );
       virtual ~CPRFilter( );
 
-    private:
+      virtual void GenerateOutputInformation( );
       virtual void GenerateData( );
 
     protected:
index 5db673d3eefa5e3bdf152e891ad2504e00952d63..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,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( ) );
 }
 
index ff72c1a93e37964583d96ce9efd049dd16af146f..041d874864d7fc641cf79240c21aa659b7c0d79c 100644 (file)
@@ -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( );
index 72897d6729a615ca3368a85a62c434297e8063cf..5bafb8097b2efa475272f69fe7dad296906fa18e 100644 (file)
@@ -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
index d7bbcf4e1b4c5edeed828e4144c3f210fe185f5c..1174d2b085b15937dcc6af1c553c885b0f62ca58 100644 (file)
@@ -41,7 +41,8 @@ IsValid( ) const
 // -------------------------------------------------------------------------
 cpPlugins::Interface::InputProcessObjectPort::
 InputProcessObjectPort( bool required )
-  : Superclass( )
+  : Superclass( ),
+    m_Required( required )
 {
 }