]> Creatis software - cpPlugins.git/commitdiff
...
authorLeonardo Flórez-Valencia <florez-l@javeriana.edu.co>
Tue, 6 Dec 2016 00:09:59 +0000 (19:09 -0500)
committerLeonardo Flórez-Valencia <florez-l@javeriana.edu.co>
Tue, 6 Dec 2016 00:09:59 +0000 (19:09 -0500)
16 files changed:
lib/cpExtensions/DataStructures/FourierSeriesContour.cxx
lib/cpExtensions/DataStructures/FourierSeriesContour.h
lib/cpInstances/CMakeLists.txt
lib/cpInstances/ITKImageInterpolators.i
lib/cpPlugins/BaseObjects/Parameters.cxx
plugins/CMakeLists.txt
plugins/ITKImageInterpolators/BSplineInterpolateImageFunction.cxx [new file with mode: 0644]
plugins/ITKImageInterpolators/BSplineInterpolateImageFunction.h [new file with mode: 0644]
plugins/ITKImageInterpolators/InterpolateImageFunction.cxx [new file with mode: 0644]
plugins/ITKImageInterpolators/InterpolateImageFunction.h [new file with mode: 0644]
plugins/ITKImageInterpolators/LinearInterpolateImageFunction.cxx [new file with mode: 0644]
plugins/ITKImageInterpolators/LinearInterpolateImageFunction.h [new file with mode: 0644]
plugins/ITKSliceFilters/CPRImageFilter.cxx
plugins/ITKSliceFilters/ITKSliceFilters.i [new file with mode: 0644]
plugins/ITKSliceFilters/IsoResampleImageFilter.cxx [new file with mode: 0644]
plugins/ITKSliceFilters/IsoResampleImageFilter.h [new file with mode: 0644]

index 989b0bcfaad13f807d24021fe0e8169819dd29c2..679f21660ada88e149f922ade876814a4e8d17ea 100644 (file)
@@ -26,7 +26,7 @@ template< class _TScalar >
 _TScalar cpExtensions::DataStructures::FourierSeriesContour< _TScalar >::
 GetArea( ) const
 {
-  S a = TScalar( 0 );
+  TScalar a = TScalar( 0 );
   int q = this->GetNumberOfHarmonics( );
   typename Self::const_iterator i = this->begin( );
   for( int l = -q; i != this->end( ); ++i, ++l )
@@ -403,7 +403,7 @@ operator&( const _TScalar& phase ) const
   int q = this->GetNumberOfHarmonics( );
   typename Self::const_iterator i = this->begin( );
   for( int l = -q; i != this->end( ); ++i, ++l )
-    res.push_back( *i * std::polar( S( 1 ), S( l ) * phase ) );
+    res.push_back( *i * std::polar( TScalar( 1 ), TScalar( l ) * phase ) );
   return( res );
 }
 
@@ -416,7 +416,7 @@ operator&=( const _TScalar& phase )
   int q = this->GetNumberOfHarmonics( );
   typename Self::iterator i = this->begin( );
   for( int l = -q; i != this->end( ); ++i, ++l )
-    *i *= std::polar( S( 1 ), S( l ) * phase );
+    *i *= std::polar( TScalar( 1 ), TScalar( l ) * phase );
   return( *this );
 }
 
@@ -473,8 +473,8 @@ GetPhase( const _TScalar& w ) const
     // 1.1. Roughly sample phases
     for( unsigned int s = 0; s < _samples; ++s )
     {
-      S w = TScalar( s ) * _angleOff;
-      S a = std::arg( contour._Z( w, 0 ) );
+      TScalar w = TScalar( s ) * _angleOff;
+      TScalar a = std::arg( contour._Z( w, 0 ) );
       function.push_back( std::pair< TScalar, TScalar >( w, a ) );
       if( a < minA )
       {
@@ -545,7 +545,7 @@ Sample( std::vector< TPoint >& p, const unsigned long& s ) const
   static const TScalar _2pi = TScalar( 2 ) * TScalar( vnl_math::pi );
   TScalar off = _2pi / TScalar( s - 1 );
   for( unsigned int w = 0; w < s; ++w )
-    p.push_back( ( *this )( S( w ) * off ) );
+    p.push_back( ( *this )( TScalar( w ) * off ) );
 }
 
 // -------------------------------------------------------------------------
@@ -571,8 +571,12 @@ GetEllipse( int l, _TScalar& a, _TScalar& b, _TScalar& t, _TScalar& p ) const
   {
     zp /= np;
     zn /= nn;
-    t = std::real( std::log( zp * zn ) / TComplex( TScalar( 0 ), S( 2 ) ) );
-    p = std::real( std::log( zp / zn ) / TComplex( TScalar( 0 ), S( 2 * l ) ) );
+    t = std::real(
+      std::log( zp * zn ) / TComplex( TScalar( 0 ), TScalar( 2 ) )
+      );
+    p = std::real(
+      std::log( zp / zn ) / TComplex( TScalar( 0 ), TScalar( 2 * l ) )
+      );
   }
   else
   {
@@ -623,7 +627,7 @@ template< class _TScalar >
 void cpExtensions::DataStructures::FourierSeriesContour< _TScalar >::
 _DFT( const std::vector< TComplex >& p, unsigned int q )
 {
-  static const S _2pi = TScalar( 2 ) * TScalar( vnl_math::pi );
+  static const TScalar _2pi = TScalar( 2 ) * TScalar( vnl_math::pi );
 
   this->SetNumberOfHarmonics( q );
   *this *= TScalar( 0 );
index 56ad8531c8afba5d2e157130a01945acd2fd92e0..3590549f68ea460620c3fa22d8d03755eefdd23f 100644 (file)
@@ -19,33 +19,33 @@ namespace cpExtensions
      *
      */
     template< class _TScalar >
-    class cpExtensions_EXPORT FourierSeries
+    class cpExtensions_EXPORT FourierSeriesContour
       : public std::deque< std::complex< _TScalar > >
     {
     public:
-      typedef FourierSeries               Self;
-      typedef _TScalar                    TScalar;
-      typedef itk::Matrix< S, 2, 2 >      TMatrix;
-      typedef itk::Point< S, 2 >          TPoint;
-      typedef typename TPoint::VectorType TVector;
-      typedef std::complex< S >           TComplex;
-      typedef std::deque< TComplex >      Superclass;
+      typedef FourierSeriesContour         Self;
+      typedef _TScalar                     TScalar;
+      typedef itk::Matrix< TScalar, 2, 2 > TMatrix;
+      typedef itk::Point< TScalar, 2 >     TPoint;
+      typedef typename TPoint::VectorType  TVector;
+      typedef std::complex< TScalar >      TComplex;
+      typedef std::deque< TComplex >       Superclass;
 
     public:
-      FourierSeries( unsigned int q = 1 );
+      FourierSeriesContour( unsigned int q = 1 );
 
       template< class _TScalar2 >
-      FourierSeries( const FourierSeries< _TScalar2 >& o );
+      FourierSeriesContour( const FourierSeriesContour< _TScalar2 >& o );
 
       template< class _TIterator >
-      FourierSeries(
+      FourierSeriesContour(
         const _TIterator& b, const _TIterator& e, unsigned int q
         );
 
-      virtual ~FourierSeries( );
+      virtual ~FourierSeriesContour( );
 
       template< class _TScalar2 >
-      Self& operator=( const FourierSeries< _TSCalar2 >& o );
+      Self& operator=( const FourierSeriesContour< _TScalar2 >& o );
 
       bool operator==( const Self& o ) const { return( false ); }
       bool operator!=( const Self& o ) const { return( true ); }
index ece1f31bac6473e0f68e1125373d9de8d05ed893..031e9602bebc87dd39964b14eb0570fc2c477c8f 100644 (file)
@@ -25,7 +25,6 @@ CreateLib(
   ${CMAKE_CURRENT_SOURCE_DIR}/ITKMeshes.i
   ${CMAKE_CURRENT_SOURCE_DIR}/ITKPaths.i
   ${CMAKE_CURRENT_SOURCE_DIR}/ITKTransforms.i
-  ${CMAKE_CURRENT_SOURCE_DIR}/ITKImageInterpolators.i
   )
 TARGET_LINK_LIBRARIES(
   ${_pfx}ITKDataObjects
@@ -43,6 +42,16 @@ TARGET_LINK_LIBRARIES(
   ${_pfx}ITKDataObjects
   )
 
+CreateLib(
+  ${_pfx}ITKImageInterpolators
+  SHARED
+  ${CMAKE_CURRENT_SOURCE_DIR}/ITKImageInterpolators.i
+  )
+TARGET_LINK_LIBRARIES(
+  ${_pfx}ITKImageInterpolators
+  ${_pfx}ITKBaseImageFilters
+  )
+
 CreateLib(
   ${_pfx}ITKBaseImageFilters
   SHARED
@@ -79,6 +88,7 @@ CreateLib(
 TARGET_LINK_LIBRARIES(
   cpPluginsDataObjects
   cpPlugins
+  cpExtensions
   ${_pfx}ITKBaseImageFilters
   )
 
@@ -91,6 +101,7 @@ SET(
   ${_pfx}ITKBaseObjects
   ${_pfx}ITKDataObjects
   ${_pfx}ITKImageIterators
+  ${_pfx}ITKImageInterpolators
   ${_pfx}ITKBaseImageFilters
   CACHE INTERNAL "All valid instances." FORCE
   )
index caaff5d5acc476902bf4e05a2b85da56267c52d4..c6c5f9c93e64c0dc281cf6c56049ebeb5298c485 100644 (file)
@@ -17,4 +17,9 @@ instances itk::#interp#InterpolateImageFunction< itk::Image< #scalar_types#, #pd
 
 instances itk::VectorLinearInterpolateImageFunction< itk::Image< itk::#v#< #i_real#, #pdims# >, #pdims# >, #o_real# >
 
+tinclude itkBSplineDecompositionImageFilter:h|hxx
+tinclude itkBSplineInterpolateImageFunction:h|hxx
+instances itk::BSplineInterpolateImageFunction< itk::Image< #scalar_types#, #pdims# >, #real_types#, #real_types# >
+instances itk::BSplineDecompositionImageFilter< itk::Image< #scalar_types#, #pdims# >, itk::Image< #real_types#, #pdims# > >
+
 ** eof - $RCSfile$
index cfb5f83b220aaa3b0a8488887932aa2df34c8deb..4025461f345cc060d294880281c3c9f9b4d989f3 100644 (file)
@@ -200,6 +200,7 @@ ConfigureAsRealTypesChoices( const std::string& name )
   choices.push_back( "float" );
   choices.push_back( "double" );
   this->ConfigureAsChoices( name, choices );
+  this->SetSelectedChoice( name, "float" );
 }
 
 // -------------------------------------------------------------------------
@@ -216,6 +217,7 @@ ConfigureAsIntTypesChoices( const std::string& name )
   choices.push_back( "long" );
   choices.push_back( "ulong" );
   this->ConfigureAsChoices( name, choices );
+  this->SetSelectedChoice( name, "char" );
 }
 
 // -------------------------------------------------------------------------
@@ -234,6 +236,7 @@ ConfigureAsScalarTypesChoices( const std::string& name )
   choices.push_back( "float" );
   choices.push_back( "double" );
   this->ConfigureAsChoices( name, choices );
+  this->SetSelectedChoice( name, "char" );
 }
 
 // -------------------------------------------------------------------------
index 53d00f8cd5bcd1185dd214183bf10bcb210ec083..9a44ffb0f25ba452ba6b1558e865e59720d79c69 100644 (file)
@@ -20,6 +20,8 @@ SET(
   ITKSeparableFilters
   ITKMorphology
   ITKParaMorphology
+  ITKSliceFilters
+  ITKImageInterpolators
   cpExtensions
   )
 
@@ -68,5 +70,9 @@ TARGET_LINK_LIBRARIES(
   cpPluginsITKMorphology
   cpPluginsITKUnaryFunctorFilters
   )
+TARGET_LINK_LIBRARIES(
+  cpPluginsITKSliceFilters
+  cpPluginsITKImageInterpolators
+  )
 
 ## eof - $RCSfile$
diff --git a/plugins/ITKImageInterpolators/BSplineInterpolateImageFunction.cxx b/plugins/ITKImageInterpolators/BSplineInterpolateImageFunction.cxx
new file mode 100644 (file)
index 0000000..49af74c
--- /dev/null
@@ -0,0 +1,62 @@
+#include <ITKImageInterpolators/BSplineInterpolateImageFunction.h>
+#include <cpInstances/Image.h>
+#include <itkImage.h>
+#include <itkBSplineInterpolateImageFunction.h>
+
+// -------------------------------------------------------------------------
+cpPluginsITKImageInterpolators::BSplineInterpolateImageFunction::
+BSplineInterpolateImageFunction( )
+  : Superclass( )
+{
+  this->m_Parameters.ConfigureAsUint( "SplineOrder", 3 );
+  this->m_Parameters.ConfigureAsBool( "UseImageDirection", true );
+}
+
+// -------------------------------------------------------------------------
+cpPluginsITKImageInterpolators::BSplineInterpolateImageFunction::
+~BSplineInterpolateImageFunction( )
+{
+}
+
+// -------------------------------------------------------------------------
+void cpPluginsITKImageInterpolators::BSplineInterpolateImageFunction::
+CreateInterpolator(
+  itk::LightObject* image, const std::string& precision_type
+  )
+{
+  this->m_PrecisionType = precision_type;
+  cpPlugins_Demangle_Image_ScalarPixels_AllDims_1( image, _GD0 )
+    this->_Error( "Invalid input image." );
+}
+
+// -------------------------------------------------------------------------
+void cpPluginsITKImageInterpolators::BSplineInterpolateImageFunction::
+_GenerateData( )
+{
+}
+
+// -------------------------------------------------------------------------
+template< class _TImage >
+void cpPluginsITKImageInterpolators::BSplineInterpolateImageFunction::
+_GD0( _TImage* image )
+{
+  if( this->m_PrecisionType == "float" )
+    this->_GD1< _TImage, float >( image );
+  else if( this->m_PrecisionType == "double" )
+    this->_GD1< _TImage, double >( image );
+}
+
+// -------------------------------------------------------------------------
+template< class _TImage, class _TScalar >
+void cpPluginsITKImageInterpolators::BSplineInterpolateImageFunction::
+_GD1( _TImage* image )
+{
+  typedef itk::BSplineInterpolateImageFunction< _TImage, _TScalar, _TScalar > _TFunction;
+
+  auto function = this->_CreateITK< _TFunction >( );
+  function->SetSplineOrder( this->m_Parameters.GetUint( "SplineOrder" ) );
+  function->SetUseImageDirection( this->m_Parameters.GetBool( "UseImageDirection" ) );
+  this->GetOutput( "Output" )->SetITK( function );
+}
+
+// eof - $RCSfile$
diff --git a/plugins/ITKImageInterpolators/BSplineInterpolateImageFunction.h b/plugins/ITKImageInterpolators/BSplineInterpolateImageFunction.h
new file mode 100644 (file)
index 0000000..f227327
--- /dev/null
@@ -0,0 +1,38 @@
+#ifndef __cpPluginsITKImageInterpolators__BSplineInterpolateImageFunction__h__
+#define __cpPluginsITKImageInterpolators__BSplineInterpolateImageFunction__h__
+
+#include <cpPluginsITKImageInterpolators_Export.h>
+#include <ITKImageInterpolators/InterpolateImageFunction.h>
+
+namespace cpPluginsITKImageInterpolators
+{
+  /**
+   */
+  class cpPluginsITKImageInterpolators_EXPORT BSplineInterpolateImageFunction
+    : public InterpolateImageFunction
+  {
+    cpPluginsObject(
+      BSplineInterpolateImageFunction,
+      InterpolateImageFunction,
+      ITKImageInterpolators
+      );
+
+  public:
+    virtual void CreateInterpolator(
+      itk::LightObject* image,
+      const std::string& precision_type
+      ) cpPlugins_OVERRIDE;
+
+  protected:
+    template< class _TImage >
+    inline void _GD0( _TImage* image );
+
+    template< class _TImage, class _TScalar >
+    inline void _GD1( _TImage* image );
+  };
+
+} // ecapseman
+
+#endif // __cpPluginsITKImageInterpolators__BSplineInterpolateImageFunction__h__
+
+// eof - $RCSfile$
diff --git a/plugins/ITKImageInterpolators/InterpolateImageFunction.cxx b/plugins/ITKImageInterpolators/InterpolateImageFunction.cxx
new file mode 100644 (file)
index 0000000..8d85bc9
--- /dev/null
@@ -0,0 +1,23 @@
+#include <ITKImageInterpolators/InterpolateImageFunction.h>
+
+// -------------------------------------------------------------------------
+cpPluginsITKImageInterpolators::InterpolateImageFunction::
+InterpolateImageFunction( )
+  : Superclass( )
+{
+  this->_ConfigureOutput< cpPlugins::BaseObjects::DataObject >( "Output" );
+}
+
+// -------------------------------------------------------------------------
+cpPluginsITKImageInterpolators::InterpolateImageFunction::
+~InterpolateImageFunction( )
+{
+}
+
+// -------------------------------------------------------------------------
+void cpPluginsITKImageInterpolators::InterpolateImageFunction::
+_GenerateData( )
+{
+}
+
+// eof - $RCSfile$
diff --git a/plugins/ITKImageInterpolators/InterpolateImageFunction.h b/plugins/ITKImageInterpolators/InterpolateImageFunction.h
new file mode 100644 (file)
index 0000000..88b8b58
--- /dev/null
@@ -0,0 +1,50 @@
+#ifndef __cpPluginsITKImageInterpolators__InterpolateImageFunction__h__
+#define __cpPluginsITKImageInterpolators__InterpolateImageFunction__h__
+
+#include <cpPluginsITKImageInterpolators_Export.h>
+#include <cpPlugins/BaseObjects/ProcessObject.h>
+
+namespace cpPluginsITKImageInterpolators
+{
+  /**
+   */
+  class cpPluginsITKImageInterpolators_EXPORT InterpolateImageFunction
+    : public cpPlugins::BaseObjects::ProcessObject
+  {
+  public:
+    typedef InterpolateImageFunction              Self;
+    typedef cpPlugins::BaseObjects::ProcessObject Superclass;
+    typedef itk::SmartPointer< Self >             Pointer;
+    typedef itk::SmartPointer< const Self >       ConstPointer;
+
+  public:
+    itkTypeMacro( BaseFilter, cpPlugins::BaseObjects::ProcessObject );
+    cpPlugins_Id_Macro( InterpolateImageFunction, ImageInterpolators );
+
+  protected:
+    InterpolateImageFunction( );
+    virtual ~InterpolateImageFunction( );
+
+  public:
+    virtual void CreateInterpolator(
+      itk::LightObject* image,
+      const std::string& precision_type
+      ) = 0;
+
+  protected:
+    virtual void _GenerateData( ) cpPlugins_OVERRIDE;
+
+  private:
+    // Purposely not implemented.
+    InterpolateImageFunction( const Self& other );
+    Self& operator=( const Self& other );
+
+  protected:
+    std::string m_PrecisionType;
+  };
+
+} // ecapseman
+
+#endif // __cpPluginsITKImageInterpolators__InterpolateImageFunction__h__
+
+// eof - $RCSfile$
diff --git a/plugins/ITKImageInterpolators/LinearInterpolateImageFunction.cxx b/plugins/ITKImageInterpolators/LinearInterpolateImageFunction.cxx
new file mode 100644 (file)
index 0000000..55a3c37
--- /dev/null
@@ -0,0 +1,58 @@
+#include <ITKImageInterpolators/LinearInterpolateImageFunction.h>
+#include <cpInstances/Image.h>
+#include <itkImage.h>
+#include <itkLinearInterpolateImageFunction.h>
+
+// -------------------------------------------------------------------------
+cpPluginsITKImageInterpolators::LinearInterpolateImageFunction::
+LinearInterpolateImageFunction( )
+  : Superclass( )
+{
+}
+
+// -------------------------------------------------------------------------
+cpPluginsITKImageInterpolators::LinearInterpolateImageFunction::
+~LinearInterpolateImageFunction( )
+{
+}
+
+// -------------------------------------------------------------------------
+void cpPluginsITKImageInterpolators::LinearInterpolateImageFunction::
+CreateInterpolator(
+  itk::LightObject* image, const std::string& precision_type
+  )
+{
+  this->m_PrecisionType = precision_type;
+  cpPlugins_Demangle_Image_ScalarPixels_AllDims_1( image, _GD0 )
+    this->_Error( "Invalid input image." );
+}
+
+// -------------------------------------------------------------------------
+void cpPluginsITKImageInterpolators::LinearInterpolateImageFunction::
+_GenerateData( )
+{
+}
+
+// -------------------------------------------------------------------------
+template< class _TImage >
+void cpPluginsITKImageInterpolators::LinearInterpolateImageFunction::
+_GD0( _TImage* image )
+{
+  if( this->m_PrecisionType == "float" )
+    this->_GD1< _TImage, float >( image );
+  else if( this->m_PrecisionType == "double" )
+    this->_GD1< _TImage, double >( image );
+}
+
+// -------------------------------------------------------------------------
+template< class _TImage, class _TScalar >
+void cpPluginsITKImageInterpolators::LinearInterpolateImageFunction::
+_GD1( _TImage* image )
+{
+  typedef itk::LinearInterpolateImageFunction< _TImage, _TScalar > _TFunction;
+
+  auto function = this->_CreateITK< _TFunction >( );
+  this->GetOutput( "Output" )->SetITK( function );
+}
+
+// eof - $RCSfile$
diff --git a/plugins/ITKImageInterpolators/LinearInterpolateImageFunction.h b/plugins/ITKImageInterpolators/LinearInterpolateImageFunction.h
new file mode 100644 (file)
index 0000000..6b3aabf
--- /dev/null
@@ -0,0 +1,38 @@
+#ifndef __cpPluginsITKImageInterpolators__LinearInterpolateImageFunction__h__
+#define __cpPluginsITKImageInterpolators__LinearInterpolateImageFunction__h__
+
+#include <cpPluginsITKImageInterpolators_Export.h>
+#include <ITKImageInterpolators/InterpolateImageFunction.h>
+
+namespace cpPluginsITKImageInterpolators
+{
+  /**
+   */
+  class cpPluginsITKImageInterpolators_EXPORT LinearInterpolateImageFunction
+    : public InterpolateImageFunction
+  {
+    cpPluginsObject(
+      LinearInterpolateImageFunction,
+      InterpolateImageFunction,
+      ITKImageInterpolators
+      );
+
+  public:
+    virtual void CreateInterpolator(
+      itk::LightObject* image,
+      const std::string& precision_type
+      ) cpPlugins_OVERRIDE;
+
+  protected:
+    template< class _TImage >
+    inline void _GD0( _TImage* image );
+
+    template< class _TImage, class _TScalar >
+    inline void _GD1( _TImage* image );
+  };
+
+} // ecapseman
+
+#endif // __cpPluginsITKImageInterpolators__LinearInterpolateImageFunction__h__
+
+// eof - $RCSfile$
index b2f14e4fd51642eac37e1a20b84b3a62338f439b..9c22570bb12e98ec4191d3a6ffd9c2240faa8996 100644 (file)
@@ -1,23 +1,28 @@
 #include <ITKSliceFilters/CPRImageFilter.h>
-#include <cpInstances/Image.h>
-#include <cpInstances/Simple3DCurve.h>
 
-#include <itkImage.h>
-#include <cpExtensions/DataStructures/Simple3DCurve.h>
-#include <cpExtensions/Algorithms/CPRImageFilter.h>
+/* TODO
+   #include <cpInstances/Image.h>
+   #include <cpInstances/Simple3DCurve.h>
+
+   #include <itkImage.h>
+   #include <cpExtensions/DataStructures/Simple3DCurve.h>
+   #include <cpExtensions/Algorithms/CPRImageFilter.h>
+*/
 
 // -------------------------------------------------------------------------
 cpPluginsITKSliceFilters::CPRImageFilter::
 CPRImageFilter( )
   : Superclass( )
 {
-  typedef cpInstances::Image         _TImage;
-  typedef cpInstances::Simple3DCurve _TCurve;
-  this->_ConfigureInput< _TImage >( "Image", true, false );
-  this->_ConfigureInput< _TCurve >( "Curve", true, false );
-  this->_ConfigureOutput< _TImage >( "Output" );
+  /* TODO
+     typedef cpInstances::Image         _TImage;
+     typedef cpInstances::Simple3DCurve _TCurve;
+     this->_ConfigureInput< _TImage >( "Image", true, false );
+     this->_ConfigureInput< _TCurve >( "Curve", true, false );
+     this->_ConfigureOutput< _TImage >( "Output" );
 
-  this->m_Parameters.ConfigureAsReal( "SliceRadius", 1 );
+     this->m_Parameters.ConfigureAsReal( "SliceRadius", 1 );
+  */
 }
 
 // -------------------------------------------------------------------------
@@ -30,9 +35,11 @@ cpPluginsITKSliceFilters::CPRImageFilter::
 void cpPluginsITKSliceFilters::CPRImageFilter::
 _GenerateData( )
 {
-  auto o = this->GetInputData( "Image" );
-  cpPlugins_Demangle_Image_ScalarPixels_1( o, _GD0, 3 )
-    this->_Error( "Invalid input image." );
+  /* TODO
+     auto o = this->GetInputData( "Image" );
+     cpPlugins_Demangle_Image_ScalarPixels_1( o, _GD0, 3 )
+     this->_Error( "Invalid input image." );
+  */
 }
 
 // -------------------------------------------------------------------------
@@ -40,9 +47,11 @@ template< class _TImage >
 void cpPluginsITKSliceFilters::CPRImageFilter::
 _GD0( _TImage* image )
 {
-  auto o = this->GetInputData( "Curve" );
-  cpPlugins_Demangle_Simple3DCurve_All_2( o, _GD1, image )
-    this->_Error( "Invalid input curve." );
+  /* TODO
+     auto o = this->GetInputData( "Curve" );
+     cpPlugins_Demangle_Simple3DCurve_All_2( o, _GD1, image )
+     this->_Error( "Invalid input curve." );
+  */
 }
 
 // -------------------------------------------------------------------------
@@ -50,14 +59,16 @@ template< class _TCurve, class _TImage >
 void cpPluginsITKSliceFilters::CPRImageFilter::
 _GD1( _TCurve* curve, _TImage* image )
 {
-  typedef cpExtensions::Algorithms::CPRImageFilter< _TImage, _TCurve > _TFilter;
-
-  auto filter = this->_CreateITK< _TFilter >( );
-  filter->SetInput( image );
-  filter->SetCurve( curve );
-  filter->SetSliceRadius( this->m_Parameters.GetReal( "SliceRadius" ) );
-  filter->Update( );
-  this->GetOutput( "Output" )->SetITK( filter->GetOutput( ) );
+  /* TODO
+     typedef cpExtensions::Algorithms::CPRImageFilter< _TImage, _TCurve > _TFilter;
+
+     auto filter = this->_CreateITK< _TFilter >( );
+     filter->SetInput( image );
+     filter->SetCurve( curve );
+     filter->SetSliceRadius( this->m_Parameters.GetReal( "SliceRadius" ) );
+     filter->Update( );
+     this->GetOutput( "Output" )->SetITK( filter->GetOutput( ) );
+  */
 }
 
 // eof - $RCSfile$
diff --git a/plugins/ITKSliceFilters/ITKSliceFilters.i b/plugins/ITKSliceFilters/ITKSliceFilters.i
new file mode 100644 (file)
index 0000000..c7966b4
--- /dev/null
@@ -0,0 +1,7 @@
+header #define ITK_MANUAL_INSTANTIATION
+
+tinclude itkResampleImageFilter:h|hxx
+
+instances itk::ResampleImageFilter< itk::Image< #scalar_types#, #pdims# >, itk::Image< #scalar_types#, #pdims# >, #real_types#, #real_types# >
+
+** eof - $RCSfile$
diff --git a/plugins/ITKSliceFilters/IsoResampleImageFilter.cxx b/plugins/ITKSliceFilters/IsoResampleImageFilter.cxx
new file mode 100644 (file)
index 0000000..77d56a6
--- /dev/null
@@ -0,0 +1,109 @@
+#include <ITKSliceFilters/IsoResampleImageFilter.h>
+#include <ITKImageInterpolators/InterpolateImageFunction.h>
+
+#include <cpInstances/Image.h>
+#include <itkImage.h>
+#include <itkResampleImageFilter.h>
+#include <itkIdentityTransform.h>
+
+// -------------------------------------------------------------------------
+cpPluginsITKSliceFilters::IsoResampleImageFilter::
+IsoResampleImageFilter( )
+  : Superclass( )
+{
+  this->_ConfigureInput< cpInstances::Image >( "Input", true, false );
+  this->_ConfigureInput< cpPlugins::BaseObjects::DataObject >( "Interpolator", false, false );
+  this->_ConfigureOutput< cpInstances::Image >( "Output" );
+
+  this->m_Parameters.ConfigureAsReal( "Scale", 1 );
+  this->m_Parameters.ConfigureAsBool( "ScaleFromMinimumSpacing", true );
+  this->m_Parameters.ConfigureAsRealTypesChoices( "PrecisionType" );
+}
+
+// -------------------------------------------------------------------------
+cpPluginsITKSliceFilters::IsoResampleImageFilter::
+~IsoResampleImageFilter( )
+{
+}
+
+// -------------------------------------------------------------------------
+void cpPluginsITKSliceFilters::IsoResampleImageFilter::
+_GenerateData( )
+{
+  auto o = this->GetInputData( "Input" );
+  cpPlugins_Demangle_Image_ScalarPixels_AllDims_1( o, _GD0 )
+    this->_Error( "Invalid input image." );
+}
+
+// -------------------------------------------------------------------------
+template< class _TImage >
+void cpPluginsITKSliceFilters::IsoResampleImageFilter::
+_GD0( _TImage* image )
+{
+  typedef cpPluginsITKImageInterpolators::InterpolateImageFunction _TInterpolator;
+
+  std::string p_type = this->m_Parameters.GetSelectedChoice( "PrecisionType" );
+  auto interpolator = dynamic_cast< _TInterpolator* >(
+    this->GetInput( "Interpolator" )->GetSource( )
+    );
+  if( interpolator != NULL )
+    interpolator->CreateInterpolator( image, p_type );
+  if     ( p_type == "float" )  this->_GD1< _TImage, float >( image );
+  else if( p_type == "double" ) this->_GD1< _TImage, double >( image );
+}
+
+// -------------------------------------------------------------------------
+template< class _TImage, class _TScalar >
+void cpPluginsITKSliceFilters::IsoResampleImageFilter::
+_GD1( _TImage* image )
+{
+  typedef itk::IdentityTransform< _TScalar, _TImage::ImageDimension > _TTransform;
+  typedef itk::ResampleImageFilter< _TImage, _TImage, _TScalar, _TScalar > _TFilter;
+  typedef typename _TFilter::InterpolatorType _TInterpolator;
+
+  // Initial configuration
+  auto filter = this->_CreateITK< _TFilter >( );
+  filter->SetInput( image );
+
+  // Associate transform
+  typename _TTransform::Pointer transform = _TTransform::New( );
+  transform->SetIdentity( );
+  filter->SetTransform( transform );
+
+  // Compute new spacing
+  typename _TImage::SpacingType in_spac = image->GetSpacing( );
+  double val_spac = in_spac[ 0 ];
+  if( this->m_Parameters.GetBool( "ScaleFromMinimumSpacing" ) )
+    for( unsigned int d = 1; d < _TImage::ImageDimension; ++d )
+      val_spac = ( in_spac[ d ] < val_spac )? in_spac[ d ]: val_spac;
+  else
+    for( unsigned int d = 1; d < _TImage::ImageDimension; ++d )
+      val_spac = ( in_spac[ d ] > val_spac )? in_spac[ d ]: val_spac;
+  val_spac *= this->m_Parameters.GetReal( "Scale" );
+  typename _TImage::SpacingType out_spac;
+  out_spac.Fill( val_spac );
+  filter->SetOutputSpacing( out_spac );
+
+  // Compute new size
+  typename _TImage::SizeType in_size = image->GetRequestedRegion( ).GetSize( );
+  typename _TImage::SizeType out_size;
+  for( unsigned int d = 0; d < _TImage::ImageDimension; ++d )
+    out_size[ d ] = ( unsigned long )(
+      double( in_size[ d ] ) * double( in_spac[ d ] ) / val_spac
+      );
+  filter->SetSize( out_size );
+
+  // New origin
+  filter->SetOutputOrigin( image->GetOrigin( ) );
+
+  // Set interpolator
+  auto interpolator = this->GetInputData< _TInterpolator >( "Interpolator" );
+  if( interpolator != NULL )
+    filter->SetInterpolator( interpolator );
+
+  // Update
+  filter->Update( );
+  this->GetOutput( "Output" )->SetITK( filter->GetOutput( ) );
+}
+
+// eof - $RCSfile$
diff --git a/plugins/ITKSliceFilters/IsoResampleImageFilter.h b/plugins/ITKSliceFilters/IsoResampleImageFilter.h
new file mode 100644 (file)
index 0000000..49cd2c1
--- /dev/null
@@ -0,0 +1,32 @@
+#ifndef __cpPluginsITKSliceFilters__IsoResampleImageFilter__h__
+#define __cpPluginsITKSliceFilters__IsoResampleImageFilter__h__
+
+#include <cpPluginsITKSliceFilters_Export.h>
+#include <cpPlugins/BaseObjects/ProcessObject.h>
+
+namespace cpPluginsITKSliceFilters
+{
+  /**
+   */
+  class cpPluginsITKSliceFilters_EXPORT IsoResampleImageFilter
+    : public cpPlugins::BaseObjects::ProcessObject
+  {
+    cpPluginsObject(
+      IsoResampleImageFilter,
+      cpPlugins::BaseObjects::ProcessObject,
+      ITKSliceFilters
+      );
+
+  protected:
+    template< class _TImage >
+    inline void _GD0( _TImage* image );
+
+    template< class _TImage, class _TScalar >
+    inline void _GD1( _TImage* image );
+  };
+
+} // ecapseman
+
+#endif // __cpPluginsITKSliceFilters__IsoResampleImageFilter__h__
+
+// eof - $RCSfile$