]> Creatis software - cpPlugins.git/commitdiff
...
authorLeonardo Florez-Valencia <florez-l@javeriana.edu.co>
Wed, 16 Sep 2015 17:29:44 +0000 (19:29 +0200)
committerLeonardo Florez-Valencia <florez-l@javeriana.edu.co>
Wed, 16 Sep 2015 17:29:44 +0000 (19:29 +0200)
19 files changed:
appli/examples/CMakeLists.txt
appli/examples/example_LoadPlugins.cxx
appli/examples/example_OtsuFilter.cxx [new file with mode: 0644]
lib/cpPlugins/Interface/Image.cxx
lib/cpPlugins/Interface/Image.h
lib/cpPlugins/Interface/Instances_itkImage.cxx
lib/cpPlugins/Interface/Parameters.cxx
lib/cpPlugins/Interface/Parameters.h
lib/cpPlugins/Interface/ProcessObject.h
lib/cpPlugins/Plugins/CMakeLists.txt
lib/cpPlugins/Plugins/Host.cxx
lib/cpPlugins/Plugins/ImageReader.cxx
lib/cpPlugins/Plugins/ImageReader.h
lib/cpPlugins/Plugins/ImageWriter.cxx
lib/cpPlugins/Plugins/ImageWriter.h
lib/cpPlugins/Plugins/OtsuThresholdImageFilter.cxx [new file with mode: 0644]
lib/cpPlugins/Plugins/OtsuThresholdImageFilter.h [new file with mode: 0644]
lib/cpPlugins/Plugins/PolyDataReader.cxx [deleted file]
lib/cpPlugins/Plugins/PolyDataReader.h [deleted file]

index 3ea27975230294088208f9d13f5d64ef59961860..92a28a597d42c255b0f0363bc5e85fbc6a1fc75d 100644 (file)
@@ -6,15 +6,16 @@
 SET(
   EXAMPLES_PROGRAMS
   ## example_TestParameters
-  ## example_LoadPlugins
+  example_LoadPlugins
   example_ReadWriteImage
+  example_MarchingCubes
+  example_OtsuFilter
   ## example_ReadImageSeriesWriteImage
   ## example_ReadQuadEdgeMesh
   ## example_RenderQuadEdgeMesh
   ## example_RGBImageToHSVChannels
   ## example_RGBImageToYPbPrChannels
   ## example_MPR
-  example_MarchingCubes
   )
 
 FOREACH(prog ${EXAMPLES_PROGRAMS}) 
index 4bc43d041b427914bbcc00ed2ac73b593316a357..e46a5db137487004897407233402a412596aa6b4 100644 (file)
@@ -18,16 +18,19 @@ int main( int argc, char* argv[] )
   typedef TInterface::TClasses            TClasses;
 
   TInterface plugins;
-  plugins.Load( plugins_file );
+  if( !plugins.Load( plugins_file ) )
+  {
+    std::cerr << "Error loading plugins file." << std::endl;
+    return( 1 );
 
+  } // fi
+  
   std::cout << "---------------------------------------------" << std::endl;
   std::cout << "Loaded classes:" << std::endl;
   TClasses::const_iterator cIt = plugins.GetClasses( ).begin( );
-  TClasses::const_iterator end_cIt = plugins.GetClasses( ).end( );
-  for( ; cIt != end_cIt; ++cIt )
+  for( ; cIt != plugins.GetClasses( ).end( ); ++cIt )
     std::cout << "  := " << cIt->first << std::endl;
   std::cout << "---------------------------------------------" << std::endl;
-
   return( 0 );
 }
 
diff --git a/appli/examples/example_OtsuFilter.cxx b/appli/examples/example_OtsuFilter.cxx
new file mode 100644 (file)
index 0000000..d076d58
--- /dev/null
@@ -0,0 +1,79 @@
+#include <cstdlib>
+#include <iostream>
+#include <string>
+
+#include <cpPlugins/Interface/Interface.h>
+#include <cpPlugins/Interface/ProcessObject.h>
+
+int main( int argc, char* argv[] )
+{
+  if( argc < 4 )
+  {
+    std::cerr
+      << "Usage: " << argv[ 0 ]
+      << " plugins_file"
+      << " input_image output_image" << std::endl;
+    return( 1 );
+
+  } // fi
+
+  // Create interface
+  typedef cpPlugins::Interface::Interface TInterface;
+  typedef TInterface::TClasses            TClasses;
+  TInterface plugins;
+  if( !plugins.Load( argv[ 1 ] ) )
+  {
+    std::cerr << "Failed to load plugins." << std::endl;
+    return( 1 );
+
+  } // fi
+
+  // Create objects
+  typedef cpPlugins::Interface::ProcessObject TProcessObject;
+  typedef cpPlugins::Interface::Parameters    TParameters;
+  cpPlugins::Interface::ProcessObject::Pointer reader, writer, otsu;
+  reader = plugins.CreateProcessObject( "cpPlugins::ImageReader" );
+  writer = plugins.CreateProcessObject( "cpPlugins::ImageWriter" );
+  otsu = plugins.CreateProcessObject( "cpPlugins::OtsuThresholdImageFilter" );
+  if( reader.IsNull( ) || writer.IsNull( ) || otsu.IsNull( ) )
+  {
+    std::cerr << "No suitable objects found in plugins." << std::endl;
+    return( 1 );
+
+  } // fi
+
+  // Configure reader
+  TParameters reader_params = reader->GetDefaultParameters( );
+  for( int i = 2; i < argc - 1; ++i )
+    reader_params.AddValueToStringList( "FileNames", argv[ i ] );
+  reader->SetParameters( reader_params );
+
+  // Configure otsu
+  TParameters otsu_params = otsu->GetDefaultParameters( );
+  otsu_params.SetValueAsUint( "NumberOfHistogramBins", 100 );
+  otsu_params.SetValueAsReal( "InsideValue", 255 );
+  otsu_params.SetValueAsReal( "OutsideValue", 0 );
+  otsu_params.SetValueAsString( "OutputType", "uchar" );
+  otsu->SetParameters( otsu_params );
+
+  // Configure writer
+  TParameters writer_params = writer->GetDefaultParameters( );
+  writer_params.SetValueAsString( "FileName", argv[ argc - 1 ] );
+  writer->SetParameters( writer_params );
+
+  // Connect pipeline
+  otsu->SetInput( 0, reader->GetOutput( 0 ) );
+  writer->SetInput( 0, otsu->GetOutput( 0 ) );
+
+  // Execute pipeline
+  std::string err = writer->Update( );
+  if( err != "" )
+  {
+    std::cerr << "ERROR: " << err << std::endl;
+    return( 1 );
+
+  } // fi
+  return( 0 );
+}
+
+// eof - $RCSfile$
index a8b1d1bcafc03650b0c1ba69b7932e58f633bb63..8ddd9ccb5abd185cb9578eb041b0d563396b95de 100644 (file)
 #include <cpPlugins/Interface/Image.h>
 
-#undef ITK_MANUAL_INSTANTIATION
+#include <complex>
+#include <vtkImageData.h>
+
+#define ITK_MANUAL_INSTANTIATION
 #include <itkImage.h>
+#include <itkImageToVTKImageFilter.h>
+
 #include <itkCovariantVector.h>
+#include <itkDiffusionTensor3D.h>
+#include <itkPoint.h>
 #include <itkRGBPixel.h>
 #include <itkRGBAPixel.h>
-#include <itkVector.h>
 #include <itkSymmetricSecondRankTensor.h>
-#include <itkDiffusionTensor3D.h>
-#include <itkImageToVTKImageFilter.h>
-#include <itkVTKImageToImageFilter.h>
-
-// -------------------------------------------------------------------------
-#define cpPlugins_Image_Pixel( p, d, o )                                \
-  if( dynamic_cast< itk::Image< p, d >* >( o ) != NULL )                \
-    this->_ITK_2_VTK_1< p, d >( o )
-
-// -------------------------------------------------------------------------
-#define cpPlugins_Image_Vector( p, d, o )                              \
-  if(                                                                  \
-    dynamic_cast< itk::Image< itk::Vector< p, d >, d >* >( o ) != NULL \
-    )                                                                  \
-    this->_ITK_2_VTK_1< itk::Vector< p, d >, d >( o )
-
-// -------------------------------------------------------------------------
-#define cpPlugins_Image_CovVector( p, d, o )                            \
-  if(                                                                   \
-    dynamic_cast< itk::Image< itk::CovariantVector< p, d >, d >* >( o ) \
-    !=                                                                  \
-    NULL                                                                \
-    )                                                                   \
-    this->_ITK_2_VTK_1< itk::CovariantVector< p, d >, d >( o )
-
-// -------------------------------------------------------------------------
-#define cpPlugins_Image_SymTensor( p, d, o )                            \
-  if(                                                                   \
-    dynamic_cast< itk::Image< itk::SymmetricSecondRankTensor< p, d >, d >* >( o ) \
-    !=                                                                  \
-    NULL                                                                \
-    )                                                                   \
-    this->_ITK_2_VTK_1< itk::SymmetricSecondRankTensor< p, d >, d >( o )
-
-// -------------------------------------------------------------------------
-#define cpPlugins_Image_RGB( p, d, o )                  \
-  cpPlugins_Image_Pixel( itk::RGBPixel< p >, d, o )
-
-// -------------------------------------------------------------------------
-#define cpPlugins_Image_RGBA( p, d, o )                 \
-  cpPlugins_Image_Pixel( itk::RGBAPixel< p >, d, o )
-
-// -------------------------------------------------------------------------
-#define cpPlugins_Image_DiffTensor( p, d, o )                   \
-  cpPlugins_Image_Pixel( itk::DiffusionTensor3D< p >, d, o )
+#include <itkVector.h>
 
 // -------------------------------------------------------------------------
 void cpPlugins::Interface::Image::
 SetITKDataObject( itk::DataObject* o )
 {
+  bool r;
   if( dynamic_cast< itk::ImageBase< 1 >* >( o ) != NULL )
-    this->_ITK_2_VTK_0< 1 >( o );
+  {
+    cpPlugins_Image_Array_Demangle(
+      itk::Vector, float, 1, 1, o, _Type, r
+      );
+    else cpPlugins_Image_Array_Demangle(
+      itk::Vector, double, 1, 1, o, _Type, r
+      );
+    else cpPlugins_Image_Array_Demangle(
+      itk::Point, float, 1, 1, o, _Type, r
+      );
+    else cpPlugins_Image_Array_Demangle(
+      itk::Point, double, 1, 1, o, _Type, r
+      );
+    else cpPlugins_Image_Array_Demangle(
+      itk::CovariantVector, float, 1, 1, o, _Type, r
+      );
+    else cpPlugins_Image_Array_Demangle(
+      itk::CovariantVector, double, 1, 1, o, _Type, r
+      );
+    else cpPlugins_Image_Array_Demangle(
+      itk::SymmetricSecondRankTensor, float, 1, 1, o, _Type, r
+      );
+    else cpPlugins_Image_Array_Demangle(
+      itk::SymmetricSecondRankTensor, double, 1, 1, o, _Type, r
+      );
+    else r = this->_Dim< 1 >( o );
+  }
   else if( dynamic_cast< itk::ImageBase< 2 >* >( o ) != NULL )
-    this->_ITK_2_VTK_0< 2 >( o );
+  {
+    cpPlugins_Image_Demangle(
+      itk::RGBPixel< char >, 2, o, _Type, r
+      );
+    else cpPlugins_Image_Demangle(
+      itk::RGBPixel< short >, 2, o, _Type, r
+      );
+    else cpPlugins_Image_Demangle(
+      itk::RGBPixel< unsigned char >, 2, o, _Type, r
+      );
+    else cpPlugins_Image_Demangle(
+      itk::RGBPixel< unsigned short >, 2, o, _Type, r
+      );
+    else cpPlugins_Image_Demangle(
+      itk::RGBAPixel< char >, 2, o, _Type, r
+      );
+    else cpPlugins_Image_Demangle(
+      itk::RGBAPixel< short >, 2, o, _Type, r
+      );
+    else cpPlugins_Image_Demangle(
+      itk::RGBAPixel< unsigned char >, 2, o, _Type, r
+      );
+    else cpPlugins_Image_Demangle(
+      itk::RGBAPixel< unsigned short >, 2, o, _Type, r
+      );
+    else cpPlugins_Image_Array_Demangle(
+      itk::Vector, float, 2, 2, o, _Type, r
+      );
+    else cpPlugins_Image_Array_Demangle(
+      itk::Vector, double, 2, 2, o, _Type, r
+      );
+    else cpPlugins_Image_Array_Demangle(
+      itk::Point, float, 2, 2, o, _Type, r
+      );
+    else cpPlugins_Image_Array_Demangle(
+      itk::Point, double, 2, 2, o, _Type, r
+      );
+    else cpPlugins_Image_Array_Demangle(
+      itk::CovariantVector, float, 2, 2, o, _Type, r
+      );
+    else cpPlugins_Image_Array_Demangle(
+      itk::CovariantVector, double, 2, 2, o, _Type, r
+      );
+    else cpPlugins_Image_Array_Demangle(
+      itk::SymmetricSecondRankTensor, float, 2, 2, o, _Type, r
+      );
+    else cpPlugins_Image_Array_Demangle(
+      itk::SymmetricSecondRankTensor, double, 2, 2, o, _Type, r
+      );
+    else r = this->_Dim< 2 >( o );
+  }
   else if( dynamic_cast< itk::ImageBase< 3 >* >( o ) != NULL )
-    this->_ITK_2_VTK_0< 3 >( o );
-  else
-    this->m_ITKObject = NULL;
+  {
+    cpPlugins_Image_Demangle(
+      itk::RGBPixel< char >, 3, o, _Type, r
+      );
+    else cpPlugins_Image_Demangle(
+      itk::RGBPixel< short >, 3, o, _Type, r
+      );
+    else cpPlugins_Image_Demangle(
+      itk::RGBPixel< unsigned char >, 3, o, _Type, r
+      );
+    else cpPlugins_Image_Demangle(
+      itk::RGBPixel< unsigned short >, 3, o, _Type, r
+      );
+    else cpPlugins_Image_Demangle(
+      itk::RGBAPixel< char >, 3, o, _Type, r
+      );
+    else cpPlugins_Image_Demangle(
+      itk::RGBAPixel< short >, 3, o, _Type, r
+      );
+    else cpPlugins_Image_Demangle(
+      itk::RGBAPixel< unsigned char >, 3, o, _Type, r
+      );
+    else cpPlugins_Image_Demangle(
+      itk::RGBAPixel< unsigned short >, 3, o, _Type, r
+      );
+    else cpPlugins_Image_Array_Demangle(
+      itk::Vector, float, 3, 3, o, _Type, r
+      );
+    else cpPlugins_Image_Array_Demangle(
+      itk::Vector, double, 3, 3, o, _Type, r
+      );
+    else cpPlugins_Image_Array_Demangle(
+      itk::Point, float, 3, 3, o, _Type, r
+      );
+    else cpPlugins_Image_Array_Demangle(
+      itk::Point, double, 3, 3, o, _Type, r
+      );
+    else cpPlugins_Image_Array_Demangle(
+      itk::CovariantVector, float, 3, 3, o, _Type, r
+      );
+    else cpPlugins_Image_Array_Demangle(
+      itk::CovariantVector, double, 3, 3, o, _Type, r
+      );
+    else cpPlugins_Image_Array_Demangle(
+      itk::SymmetricSecondRankTensor, float, 3, 3, o, _Type, r
+      );
+    else cpPlugins_Image_Array_Demangle(
+      itk::SymmetricSecondRankTensor, double, 3, 3, o, _Type, r
+      );
+    else cpPlugins_Image_Demangle(
+      itk::DiffusionTensor3D< float >, 3, o, _Type, r
+      );
+    else cpPlugins_Image_Demangle(
+      itk::DiffusionTensor3D< double >, 3, o, _Type, r
+      );
+    else r = this->_Dim< 3 >( o );
+  }
+  else if( dynamic_cast< itk::ImageBase< 4 >* >( o ) != NULL )
+  {
+    this->m_ITKObject = o;
+    this->m_VTKObject = NULL;
+    this->m_ITKvVTKConnection = NULL;
+
+  } // fi
 }
 
 // -------------------------------------------------------------------------
@@ -87,7 +187,9 @@ GetVTKImageData( )
 const vtkImageData* cpPlugins::Interface::Image::
 GetVTKImageData( ) const
 {
-  return( dynamic_cast< const vtkImageData* >( this->GetVTKDataObject( ) ) );
+  return(
+    dynamic_cast< const vtkImageData* >( this->GetVTKDataObject( ) )
+    );
 }
 
 // -------------------------------------------------------------------------
@@ -107,96 +209,66 @@ cpPlugins::Interface::Image::
 
 // -------------------------------------------------------------------------
 template< unsigned int D >
-void cpPlugins::Interface::Image::
-_ITK_2_VTK_0( itk::DataObject* o )
+bool cpPlugins::Interface::Image::
+_Dim( itk::DataObject* o )
 {
-  cpPlugins_Image_Pixel( char, D, o );
-  else cpPlugins_Image_Pixel( short, D, o );
-  else cpPlugins_Image_Pixel( int, D, o );
-  else cpPlugins_Image_Pixel( long, D, o );
-  else cpPlugins_Image_Pixel( float, D, o );
-  else cpPlugins_Image_Pixel( double, D, o );
-  else cpPlugins_Image_Pixel( unsigned char, D, o );
-  else cpPlugins_Image_Pixel( unsigned short, D, o );
-  else cpPlugins_Image_Pixel( unsigned int, D, o );
-  else cpPlugins_Image_Pixel( unsigned long, D, o );
-  else cpPlugins_Image_RGB( char, D, o );
-  else cpPlugins_Image_RGB( short, D, o );
-  else cpPlugins_Image_RGB( int, D, o );
-  else cpPlugins_Image_RGB( long, D, o );
-  else cpPlugins_Image_RGB( float, D, o );
-  else cpPlugins_Image_RGB( double, D, o );
-  else cpPlugins_Image_RGB( unsigned char, D, o );
-  else cpPlugins_Image_RGB( unsigned short, D, o );
-  else cpPlugins_Image_RGB( unsigned int, D, o );
-  else cpPlugins_Image_RGB( unsigned long, D, o );
-  else cpPlugins_Image_RGBA( char, D, o );
-  else cpPlugins_Image_RGBA( short, D, o );
-  else cpPlugins_Image_RGBA( int, D, o );
-  else cpPlugins_Image_RGBA( long, D, o );
-  else cpPlugins_Image_RGBA( float, D, o );
-  else cpPlugins_Image_RGBA( double, D, o );
-  else cpPlugins_Image_RGBA( unsigned char, D, o );
-  else cpPlugins_Image_RGBA( unsigned short, D, o );
-  else cpPlugins_Image_RGBA( unsigned int, D, o );
-  else cpPlugins_Image_RGBA( unsigned long, D, o );
-  else cpPlugins_Image_Vector( char, D, o );
-  else cpPlugins_Image_Vector( short, D, o );
-  else cpPlugins_Image_Vector( int, D, o );
-  else cpPlugins_Image_Vector( long, D, o );
-  else cpPlugins_Image_Vector( float, D, o );
-  else cpPlugins_Image_Vector( double, D, o );
-  else cpPlugins_Image_Vector( unsigned char, D, o );
-  else cpPlugins_Image_Vector( unsigned short, D, o );
-  else cpPlugins_Image_Vector( unsigned int, D, o );
-  else cpPlugins_Image_Vector( unsigned long, D, o );
-  else cpPlugins_Image_CovVector( char, D, o );
-  else cpPlugins_Image_CovVector( short, D, o );
-  else cpPlugins_Image_CovVector( int, D, o );
-  else cpPlugins_Image_CovVector( long, D, o );
-  else cpPlugins_Image_CovVector( float, D, o );
-  else cpPlugins_Image_CovVector( double, D, o );
-  else cpPlugins_Image_CovVector( unsigned char, D, o );
-  else cpPlugins_Image_CovVector( unsigned short, D, o );
-  else cpPlugins_Image_CovVector( unsigned int, D, o );
-  else cpPlugins_Image_CovVector( unsigned long, D, o );
-  else cpPlugins_Image_SymTensor( char, D, o );
-  else cpPlugins_Image_SymTensor( short, D, o );
-  else cpPlugins_Image_SymTensor( int, D, o );
-  else cpPlugins_Image_SymTensor( long, D, o );
-  else cpPlugins_Image_SymTensor( float, D, o );
-  else cpPlugins_Image_SymTensor( double, D, o );
-  else cpPlugins_Image_SymTensor( unsigned char, D, o );
-  else cpPlugins_Image_SymTensor( unsigned short, D, o );
-  else cpPlugins_Image_SymTensor( unsigned int, D, o );
-  else cpPlugins_Image_SymTensor( unsigned long, D, o );
-  else cpPlugins_Image_DiffTensor( char, D, o );
-  else cpPlugins_Image_DiffTensor( short, D, o );
-  else cpPlugins_Image_DiffTensor( int, D, o );
-  else cpPlugins_Image_DiffTensor( long, D, o );
-  else cpPlugins_Image_DiffTensor( float, D, o );
-  else cpPlugins_Image_DiffTensor( double, D, o );
-  else cpPlugins_Image_DiffTensor( unsigned char, D, o );
-  else cpPlugins_Image_DiffTensor( unsigned short, D, o );
-  else cpPlugins_Image_DiffTensor( unsigned int, D, o );
-  else cpPlugins_Image_DiffTensor( unsigned long, D, o );
+  bool r;
+  cpPlugins_Image_Demangle(
+    char, D, o, _Type, r
+    );
+  else cpPlugins_Image_Demangle(
+    short, D, o, _Type, r
+    );
+  else cpPlugins_Image_Demangle(
+    int, D, o, _Type, r
+    );
+  else cpPlugins_Image_Demangle(
+    long, D, o, _Type, r
+    );
+  else cpPlugins_Image_Demangle(
+    unsigned char, D, o, _Type, r
+    );
+  else cpPlugins_Image_Demangle(
+    unsigned short, D, o, _Type, r
+    );
+  else cpPlugins_Image_Demangle(
+    unsigned int, D, o, _Type, r
+    );
+  else cpPlugins_Image_Demangle(
+    unsigned long, D, o, _Type, r
+    );
+  else cpPlugins_Image_Demangle(
+    float, D, o, _Type, r
+    );
+  else cpPlugins_Image_Demangle(
+    double, D, o, _Type, r
+    );
+  else
+  {
+    this->m_ITKObject = o;
+    this->m_VTKObject = NULL;
+    this->m_ITKvVTKConnection = NULL;
+
+  } // fi
+  return( true );
 }
 
 // -------------------------------------------------------------------------
-template< class P, unsigned int D >
-void cpPlugins::Interface::Image::
-_ITK_2_VTK_1( itk::DataObject* o )
+template< class I >
+bool cpPlugins::Interface::Image::
+_Type( itk::DataObject* o )
 {
-  typedef itk::Image< P, D > _I;
-  typedef itk::ImageToVTKImageFilter< _I > _F;
-  
+  typedef itk::ImageToVTKImageFilter< I > _F;
+
   typename _F::Pointer f = _F::New( );
-  f->SetInput( dynamic_cast< _I* >( o ) );
+  f->SetInput( dynamic_cast< I* >( o ) );
   f->Update( );
 
   this->m_ITKObject = o;
   this->m_VTKObject = f->GetOutput( );
   this->m_ITKvVTKConnection = f;
+
+  return( true );
 }
 
 // eof - $RCSfile$
index 04d9507a1e1107bca513819c4fdd125cba8df400..a354da2d22aed395f86e4601a9b0b572a1c53948 100644 (file)
 
 class vtkImageData;
 
+// -------------------------------------------------------------------------
+#define cpPlugins_Image_Demangle( p, d, o, f, r )               \
+  if( dynamic_cast< itk::Image< p, d >* >( o ) != NULL )        \
+    r = this->f< itk::Image< p, d > >( o )
+
+// -------------------------------------------------------------------------
+#define cpPlugins_Image_Array_Demangle( a, p, da, di, o, f, r )    \
+  if( dynamic_cast< itk::Image< a< p, da >, di >* >( o ) != NULL ) \
+    r = this->f< itk::Image< a< p, da >, di > >( o )
+
+// -------------------------------------------------------------------------
 namespace cpPlugins
 {
   namespace Interface
@@ -42,10 +53,10 @@ namespace cpPlugins
       virtual ~Image( );
 
       template< unsigned int D >
-        void _ITK_2_VTK_0( itk::DataObject* o );
+        bool _Dim( itk::DataObject* o );
 
-      template< class P, unsigned int D >
-        void _ITK_2_VTK_1( itk::DataObject* o );
+      template< class I >
+        bool _Type( itk::DataObject* o );
 
     private:
       // Purposely not implemented
index f33d8d426262fba876949381152d80ae91db0736..a6308b818014874eaf4735d690c0226e5e2517ab 100644 (file)
+#include <complex>
+
 #undef ITK_MANUAL_INSTANTIATION
 #include <itkImage.h>
+#include <itkImportImageContainer.h>
+#include <itkImageToVTKImageFilter.h>
+
 #include <itkCovariantVector.h>
+#include <itkDiffusionTensor3D.h>
+#include <itkPoint.h>
 #include <itkRGBPixel.h>
 #include <itkRGBAPixel.h>
-#include <itkVector.h>
 #include <itkSymmetricSecondRankTensor.h>
-#include <itkDiffusionTensor3D.h>
-#include <itkImageToVTKImageFilter.h>
+#include <itkVector.h>
 
 // -------------------------------------------------------------------------
-#define cpPlugins_Instance_itkImage_Pixel( p, d )                       \
-  template class itk::Image< p, d >;                                    \
-  template class itk::ImageToVTKImageFilter< itk::Image< p, d > >
+#define cpPlugins_I_itk( p, d )                 \
+  template class itk::Image< p, d >;
 
 // -------------------------------------------------------------------------
-#define cpPlugins_Instance_itkImage_RGB( p, d )                 \
-  cpPlugins_Instance_itkImage_Pixel( itk::RGBPixel< p >, d )
+#define cpPlugins_I_itk_array( a, p, da, di )   \
+  template class itk::Image< a< p, da >, di >;
 
 // -------------------------------------------------------------------------
-#define cpPlugins_Instance_itkImage_RGBA( p, d )                \
-  cpPlugins_Instance_itkImage_Pixel( itk::RGBAPixel< p >, d )
+#define cpPlugins_I_itk_Container( p )                                  \
+  template class itk::ImportImageContainer< itk::SizeValueType, p >;
 
 // -------------------------------------------------------------------------
-#define cpPlugins_Instance_itkImage_Vector( p, d )                      \
-  template class itk::Image< itk::Vector< p, d >, d >;                  \
-  template class                                                        \
-  itk::ImageToVTKImageFilter< itk::Image< itk::Vector< p, d >, d > >
+#define cpPlugins_I_itk_array_Container( a, p, d )                      \
+  template class itk::ImportImageContainer< itk::SizeValueType, a< p, d > >;
 
 // -------------------------------------------------------------------------
-#define cpPlugins_Instance_itkImage_CovVector( p, d )                   \
-  template class itk::Image< itk::CovariantVector< p, d >, d >;         \
-  template class                                                        \
-  itk::ImageToVTKImageFilter< itk::Image< itk::CovariantVector< p, d >, d > >
+#define cpPlugins_I_itk_vtk( p, d )                                     \
+  template class itk::ImageToVTKImageFilter< itk::Image< p, d > >;
 
 // -------------------------------------------------------------------------
-#define cpPlugins_Instance_itkImage_SymTensor( p, d )                   \
-  template class itk::Image< itk::SymmetricSecondRankTensor< p, d >, d >; \
+#define cpPlugins_I_itk_vtk_array( a, p, da, di )                       \
   template class                                                        \
-  itk::ImageToVTKImageFilter< itk::Image< itk::SymmetricSecondRankTensor< p, d >, d > >
+  itk::ImageToVTKImageFilter< itk::Image< a< p, da > , di > >;
 
 // -------------------------------------------------------------------------
-#define cpPlugins_Instance_itkImage_DiffTensor( p, d )                  \
-  cpPlugins_Instance_itkImage_Pixel( itk::DiffusionTensor3D< p >, d )
+// Possible itk types
 
-// -------------------------------------------------------------------------
-#define cpPlugins_Instance_itkImage_DIM( d )                      \
-  cpPlugins_Instance_itkImage_Pixel( char, d );                   \
-  cpPlugins_Instance_itkImage_Pixel( short, d );                  \
-  cpPlugins_Instance_itkImage_Pixel( int, d );                    \
-  cpPlugins_Instance_itkImage_Pixel( long, d );                   \
-  cpPlugins_Instance_itkImage_Pixel( float, d );                  \
-  cpPlugins_Instance_itkImage_Pixel( double, d );                 \
-  cpPlugins_Instance_itkImage_Pixel( unsigned char, d );          \
-  cpPlugins_Instance_itkImage_Pixel( unsigned short, d );         \
-  cpPlugins_Instance_itkImage_Pixel( unsigned int, d );           \
-  cpPlugins_Instance_itkImage_Pixel( unsigned long, d );          \
-  cpPlugins_Instance_itkImage_RGB( char, d );                     \
-  cpPlugins_Instance_itkImage_RGB( short, d );                    \
-  cpPlugins_Instance_itkImage_RGB( int, d );                      \
-  cpPlugins_Instance_itkImage_RGB( long, d );                     \
-  cpPlugins_Instance_itkImage_RGB( float, d );                    \
-  cpPlugins_Instance_itkImage_RGB( double, d );                   \
-  cpPlugins_Instance_itkImage_RGB( unsigned char, d );            \
-  cpPlugins_Instance_itkImage_RGB( unsigned short, d );           \
-  cpPlugins_Instance_itkImage_RGB( unsigned int, d );             \
-  cpPlugins_Instance_itkImage_RGB( unsigned long, d );            \
-  cpPlugins_Instance_itkImage_RGBA( char, d );                    \
-  cpPlugins_Instance_itkImage_RGBA( short, d );                   \
-  cpPlugins_Instance_itkImage_RGBA( int, d );                     \
-  cpPlugins_Instance_itkImage_RGBA( long, d );                    \
-  cpPlugins_Instance_itkImage_RGBA( float, d );                   \
-  cpPlugins_Instance_itkImage_RGBA( double, d );                  \
-  cpPlugins_Instance_itkImage_RGBA( unsigned char, d );           \
-  cpPlugins_Instance_itkImage_RGBA( unsigned short, d );          \
-  cpPlugins_Instance_itkImage_RGBA( unsigned int, d );            \
-  cpPlugins_Instance_itkImage_RGBA( unsigned long, d );           \
-  cpPlugins_Instance_itkImage_Vector( char, d );                  \
-  cpPlugins_Instance_itkImage_Vector( short, d );                 \
-  cpPlugins_Instance_itkImage_Vector( int, d );                   \
-  cpPlugins_Instance_itkImage_Vector( long, d );                  \
-  cpPlugins_Instance_itkImage_Vector( float, d );                 \
-  cpPlugins_Instance_itkImage_Vector( double, d );                \
-  cpPlugins_Instance_itkImage_Vector( unsigned char, d );         \
-  cpPlugins_Instance_itkImage_Vector( unsigned short, d );        \
-  cpPlugins_Instance_itkImage_Vector( unsigned int, d );          \
-  cpPlugins_Instance_itkImage_Vector( unsigned long, d );         \
-  cpPlugins_Instance_itkImage_CovVector( char, d );               \
-  cpPlugins_Instance_itkImage_CovVector( short, d );              \
-  cpPlugins_Instance_itkImage_CovVector( int, d );                \
-  cpPlugins_Instance_itkImage_CovVector( long, d );               \
-  cpPlugins_Instance_itkImage_CovVector( float, d );              \
-  cpPlugins_Instance_itkImage_CovVector( double, d );             \
-  cpPlugins_Instance_itkImage_CovVector( unsigned char, d );      \
-  cpPlugins_Instance_itkImage_CovVector( unsigned short, d );     \
-  cpPlugins_Instance_itkImage_CovVector( unsigned int, d );       \
-  cpPlugins_Instance_itkImage_CovVector( unsigned long, d );      \
-  cpPlugins_Instance_itkImage_SymTensor( char, d );               \
-  cpPlugins_Instance_itkImage_SymTensor( short, d );              \
-  cpPlugins_Instance_itkImage_SymTensor( int, d );                \
-  cpPlugins_Instance_itkImage_SymTensor( long, d );               \
-  cpPlugins_Instance_itkImage_SymTensor( float, d );              \
-  cpPlugins_Instance_itkImage_SymTensor( double, d );             \
-  cpPlugins_Instance_itkImage_SymTensor( unsigned char, d );      \
-  cpPlugins_Instance_itkImage_SymTensor( unsigned short, d );     \
-  cpPlugins_Instance_itkImage_SymTensor( unsigned int, d );       \
-  cpPlugins_Instance_itkImage_SymTensor( unsigned long, d );      \
-  cpPlugins_Instance_itkImage_DiffTensor( char, d );              \
-  cpPlugins_Instance_itkImage_DiffTensor( short, d );             \
-  cpPlugins_Instance_itkImage_DiffTensor( int, d );               \
-  cpPlugins_Instance_itkImage_DiffTensor( long, d );              \
-  cpPlugins_Instance_itkImage_DiffTensor( float, d );             \
-  cpPlugins_Instance_itkImage_DiffTensor( double, d );            \
-  cpPlugins_Instance_itkImage_DiffTensor( unsigned char, d );     \
-  cpPlugins_Instance_itkImage_DiffTensor( unsigned short, d );    \
-  cpPlugins_Instance_itkImage_DiffTensor( unsigned int, d );      \
-  cpPlugins_Instance_itkImage_DiffTensor( unsigned long, d );
+namespace itk
+{
+  template std::ostream& operator<<(
+    std::ostream& os, const ImageRegion< 1 >& obj
+    );
+  template class Point< double, 1 >;
+  template class Vector< double, 1 >;
+
+} // ecapseman
+
+cpPlugins_I_itk_Container( char );
+cpPlugins_I_itk_Container( short );
+cpPlugins_I_itk_Container( int );
+cpPlugins_I_itk_Container( long );
+cpPlugins_I_itk_Container( unsigned char );
+cpPlugins_I_itk_Container( unsigned short );
+cpPlugins_I_itk_Container( unsigned int );
+cpPlugins_I_itk_Container( unsigned long );
+cpPlugins_I_itk_Container( float );
+cpPlugins_I_itk_Container( double );
+cpPlugins_I_itk_Container( std::complex< float > );
+cpPlugins_I_itk_Container( std::complex< double > );
+cpPlugins_I_itk_Container( itk::RGBPixel< char > );
+cpPlugins_I_itk_Container( itk::RGBPixel< short > );
+cpPlugins_I_itk_Container( itk::RGBPixel< unsigned char > );
+cpPlugins_I_itk_Container( itk::RGBPixel< unsigned short > );
+cpPlugins_I_itk_Container( itk::RGBAPixel< char > );
+cpPlugins_I_itk_Container( itk::RGBAPixel< short > );
+cpPlugins_I_itk_Container( itk::RGBAPixel< unsigned char > );
+cpPlugins_I_itk_Container( itk::RGBAPixel< unsigned short > );
+cpPlugins_I_itk_Container( itk::Offset< 1 > );
+cpPlugins_I_itk_Container( itk::Offset< 2 > );
+cpPlugins_I_itk_Container( itk::Offset< 3 > );
+cpPlugins_I_itk_Container( itk::Offset< 4 > );
+cpPlugins_I_itk_array_Container( itk::Vector, float, 1 );
+cpPlugins_I_itk_array_Container( itk::Vector, double, 1 );
+cpPlugins_I_itk_array_Container( itk::Vector, float, 2 );
+cpPlugins_I_itk_array_Container( itk::Vector, double, 2 );
+cpPlugins_I_itk_array_Container( itk::Vector, float, 3 );
+cpPlugins_I_itk_array_Container( itk::Vector, double, 3 );
+cpPlugins_I_itk_array_Container( itk::Vector, float, 4 );
+cpPlugins_I_itk_array_Container( itk::Vector, double, 4 );
+cpPlugins_I_itk_array_Container( itk::Point, float, 1 );
+cpPlugins_I_itk_array_Container( itk::Point, double, 1 );
+cpPlugins_I_itk_array_Container( itk::Point, float, 2 );
+cpPlugins_I_itk_array_Container( itk::Point, double, 2 );
+cpPlugins_I_itk_array_Container( itk::Point, float, 3 );
+cpPlugins_I_itk_array_Container( itk::Point, double, 3 );
+cpPlugins_I_itk_array_Container( itk::Point, float, 4 );
+cpPlugins_I_itk_array_Container( itk::Point, double, 4 );
+cpPlugins_I_itk_array_Container( itk::CovariantVector, float, 1 );
+cpPlugins_I_itk_array_Container( itk::CovariantVector, double, 1 );
+cpPlugins_I_itk_array_Container( itk::CovariantVector, float, 2 );
+cpPlugins_I_itk_array_Container( itk::CovariantVector, double, 2 );
+cpPlugins_I_itk_array_Container( itk::CovariantVector, float, 3 );
+cpPlugins_I_itk_array_Container( itk::CovariantVector, double, 3 );
+cpPlugins_I_itk_array_Container( itk::CovariantVector, float, 4 );
+cpPlugins_I_itk_array_Container( itk::CovariantVector, double, 4 );
+cpPlugins_I_itk_array_Container( itk::SymmetricSecondRankTensor, float, 1 );
+cpPlugins_I_itk_array_Container( itk::SymmetricSecondRankTensor, double, 1 );
+cpPlugins_I_itk_array_Container( itk::SymmetricSecondRankTensor, float, 2 );
+cpPlugins_I_itk_array_Container( itk::SymmetricSecondRankTensor, double, 2 );
+cpPlugins_I_itk_array_Container( itk::SymmetricSecondRankTensor, float, 3 );
+cpPlugins_I_itk_array_Container( itk::SymmetricSecondRankTensor, double, 3 );
+cpPlugins_I_itk_array_Container( itk::SymmetricSecondRankTensor, float, 4 );
+cpPlugins_I_itk_array_Container( itk::SymmetricSecondRankTensor, double, 4 );
+cpPlugins_I_itk_Container( itk::DiffusionTensor3D< float > );
+cpPlugins_I_itk_Container( itk::DiffusionTensor3D< double > );
+
+cpPlugins_I_itk( char, 1 );
+cpPlugins_I_itk( short, 1 );
+cpPlugins_I_itk( int, 1 );
+cpPlugins_I_itk( long, 1 );
+cpPlugins_I_itk( unsigned char, 1 );
+cpPlugins_I_itk( unsigned short, 1 );
+cpPlugins_I_itk( unsigned int, 1 );
+cpPlugins_I_itk( unsigned long, 1 );
+cpPlugins_I_itk( float, 1 );
+cpPlugins_I_itk( double, 1 );
+
+cpPlugins_I_itk( char, 2 );
+cpPlugins_I_itk( short, 2 );
+cpPlugins_I_itk( int, 2 );
+cpPlugins_I_itk( long, 2 );
+cpPlugins_I_itk( unsigned char, 2 );
+cpPlugins_I_itk( unsigned short, 2 );
+cpPlugins_I_itk( unsigned int, 2 );
+cpPlugins_I_itk( unsigned long, 2 );
+cpPlugins_I_itk( float, 2 );
+cpPlugins_I_itk( double, 2 );
+
+cpPlugins_I_itk( char, 3 );
+cpPlugins_I_itk( short, 3 );
+cpPlugins_I_itk( int, 3 );
+cpPlugins_I_itk( long, 3 );
+cpPlugins_I_itk( unsigned char, 3 );
+cpPlugins_I_itk( unsigned short, 3 );
+cpPlugins_I_itk( unsigned int, 3 );
+cpPlugins_I_itk( unsigned long, 3 );
+cpPlugins_I_itk( float, 3 );
+cpPlugins_I_itk( double, 3 );
+
+cpPlugins_I_itk( char, 4 );
+cpPlugins_I_itk( short, 4 );
+cpPlugins_I_itk( int, 4 );
+cpPlugins_I_itk( long, 4 );
+cpPlugins_I_itk( unsigned char, 4 );
+cpPlugins_I_itk( unsigned short, 4 );
+cpPlugins_I_itk( unsigned int, 4 );
+cpPlugins_I_itk( unsigned long, 4 );
+cpPlugins_I_itk( float, 4 );
+cpPlugins_I_itk( double, 4 );
+
+cpPlugins_I_itk( std::complex< float >, 1 );
+cpPlugins_I_itk( std::complex< double >, 1 );
+
+cpPlugins_I_itk( std::complex< float >, 2 );
+cpPlugins_I_itk( std::complex< double >, 2 );
+
+cpPlugins_I_itk( std::complex< float >, 3 );
+cpPlugins_I_itk( std::complex< double >, 3 );
+
+cpPlugins_I_itk( std::complex< float >, 4 );
+cpPlugins_I_itk( std::complex< double >, 4 );
+
+cpPlugins_I_itk( itk::RGBPixel< char >, 2 );
+cpPlugins_I_itk( itk::RGBPixel< short >, 2 );
+cpPlugins_I_itk( itk::RGBPixel< unsigned char >, 2 );
+cpPlugins_I_itk( itk::RGBPixel< unsigned short >, 2 );
+
+cpPlugins_I_itk( itk::RGBPixel< char >, 3 );
+cpPlugins_I_itk( itk::RGBPixel< short >, 3 );
+cpPlugins_I_itk( itk::RGBPixel< unsigned char >, 3 );
+cpPlugins_I_itk( itk::RGBPixel< unsigned short >, 3 );
+
+cpPlugins_I_itk( itk::RGBPixel< char >, 4 );
+cpPlugins_I_itk( itk::RGBPixel< short >, 4 );
+cpPlugins_I_itk( itk::RGBPixel< unsigned char >, 4 );
+cpPlugins_I_itk( itk::RGBPixel< unsigned short >, 4 );
+
+cpPlugins_I_itk( itk::RGBAPixel< char >, 2 );
+cpPlugins_I_itk( itk::RGBAPixel< short >, 2 );
+cpPlugins_I_itk( itk::RGBAPixel< unsigned char >, 2 );
+cpPlugins_I_itk( itk::RGBAPixel< unsigned short >, 2 );
+
+cpPlugins_I_itk( itk::RGBAPixel< char >, 3 );
+cpPlugins_I_itk( itk::RGBAPixel< short >, 3 );
+cpPlugins_I_itk( itk::RGBAPixel< unsigned char >, 3 );
+cpPlugins_I_itk( itk::RGBAPixel< unsigned short >, 3 );
+
+cpPlugins_I_itk( itk::RGBAPixel< char >, 4 );
+cpPlugins_I_itk( itk::RGBAPixel< short >, 4 );
+cpPlugins_I_itk( itk::RGBAPixel< unsigned char >, 4 );
+cpPlugins_I_itk( itk::RGBAPixel< unsigned short >, 4 );
+
+cpPlugins_I_itk( itk::Offset< 1 >, 1 );
+cpPlugins_I_itk( itk::Offset< 2 >, 2 );
+cpPlugins_I_itk( itk::Offset< 3 >, 3 );
+cpPlugins_I_itk( itk::Offset< 4 >, 4 );
+
+cpPlugins_I_itk_array( itk::Vector, float, 1, 1 );
+cpPlugins_I_itk_array( itk::Vector, double, 1, 1 );
+cpPlugins_I_itk_array( itk::Vector, float, 2, 2 );
+cpPlugins_I_itk_array( itk::Vector, double, 2, 2 );
+cpPlugins_I_itk_array( itk::Vector, float, 3, 3 );
+cpPlugins_I_itk_array( itk::Vector, double, 3, 3 );
+cpPlugins_I_itk_array( itk::Vector, float, 4, 4 );
+cpPlugins_I_itk_array( itk::Vector, double, 4, 4 );
+
+cpPlugins_I_itk_array( itk::Point, float, 1, 1 );
+cpPlugins_I_itk_array( itk::Point, double, 1, 1 );
+cpPlugins_I_itk_array( itk::Point, float, 2, 2 );
+cpPlugins_I_itk_array( itk::Point, double, 2, 2 );
+cpPlugins_I_itk_array( itk::Point, float, 3, 3 );
+cpPlugins_I_itk_array( itk::Point, double, 3, 3 );
+cpPlugins_I_itk_array( itk::Point, float, 4, 4 );
+cpPlugins_I_itk_array( itk::Point, double, 4, 4 );
+
+cpPlugins_I_itk_array( itk::CovariantVector, float, 1, 1 );
+cpPlugins_I_itk_array( itk::CovariantVector, double, 1, 1 );
+cpPlugins_I_itk_array( itk::CovariantVector, float, 2, 2 );
+cpPlugins_I_itk_array( itk::CovariantVector, double, 2, 2 );
+cpPlugins_I_itk_array( itk::CovariantVector, float, 3, 3 );
+cpPlugins_I_itk_array( itk::CovariantVector, double, 3, 3 );
+cpPlugins_I_itk_array( itk::CovariantVector, float, 4, 4 );
+cpPlugins_I_itk_array( itk::CovariantVector, double, 4, 4 );
+
+cpPlugins_I_itk_array( itk::SymmetricSecondRankTensor, float, 1, 1 );
+cpPlugins_I_itk_array( itk::SymmetricSecondRankTensor, double, 1, 1 );
+cpPlugins_I_itk_array( itk::SymmetricSecondRankTensor, float, 2, 2 );
+cpPlugins_I_itk_array( itk::SymmetricSecondRankTensor, double, 2, 2 );
+cpPlugins_I_itk_array( itk::SymmetricSecondRankTensor, float, 3, 3 );
+cpPlugins_I_itk_array( itk::SymmetricSecondRankTensor, double, 3, 3 );
+cpPlugins_I_itk_array( itk::SymmetricSecondRankTensor, float, 4, 4 );
+cpPlugins_I_itk_array( itk::SymmetricSecondRankTensor, double, 4, 4 );
+
+cpPlugins_I_itk( itk::DiffusionTensor3D< float >, 3 );
+cpPlugins_I_itk( itk::DiffusionTensor3D< double >, 3 );
+
+/* TODO
+ * itk::FixedArray
+ * itk::Matrix
+ */
 
 // -------------------------------------------------------------------------
-cpPlugins_Instance_itkImage_DIM( 1 );
-cpPlugins_Instance_itkImage_DIM( 2 );
-cpPlugins_Instance_itkImage_DIM( 3 );
+// Possible itk types that could be connected to vtk
+
+cpPlugins_I_itk_vtk( char, 1 );
+cpPlugins_I_itk_vtk( short, 1 );
+cpPlugins_I_itk_vtk( int, 1 );
+cpPlugins_I_itk_vtk( long, 1 );
+cpPlugins_I_itk_vtk( unsigned char, 1 );
+cpPlugins_I_itk_vtk( unsigned short, 1 );
+cpPlugins_I_itk_vtk( unsigned int, 1 );
+cpPlugins_I_itk_vtk( unsigned long, 1 );
+cpPlugins_I_itk_vtk( float, 1 );
+cpPlugins_I_itk_vtk( double, 1 );
+
+cpPlugins_I_itk_vtk( char, 2 );
+cpPlugins_I_itk_vtk( short, 2 );
+cpPlugins_I_itk_vtk( int, 2 );
+cpPlugins_I_itk_vtk( long, 2 );
+cpPlugins_I_itk_vtk( unsigned char, 2 );
+cpPlugins_I_itk_vtk( unsigned short, 2 );
+cpPlugins_I_itk_vtk( unsigned int, 2 );
+cpPlugins_I_itk_vtk( unsigned long, 2 );
+cpPlugins_I_itk_vtk( float, 2 );
+cpPlugins_I_itk_vtk( double, 2 );
+
+cpPlugins_I_itk_vtk( char, 3 );
+cpPlugins_I_itk_vtk( short, 3 );
+cpPlugins_I_itk_vtk( int, 3 );
+cpPlugins_I_itk_vtk( long, 3 );
+cpPlugins_I_itk_vtk( unsigned char, 3 );
+cpPlugins_I_itk_vtk( unsigned short, 3 );
+cpPlugins_I_itk_vtk( unsigned int, 3 );
+cpPlugins_I_itk_vtk( unsigned long, 3 );
+cpPlugins_I_itk_vtk( float, 3 );
+cpPlugins_I_itk_vtk( double, 3 );
+
+cpPlugins_I_itk_vtk( itk::RGBPixel< char >, 2 );
+cpPlugins_I_itk_vtk( itk::RGBPixel< short >, 2 );
+cpPlugins_I_itk_vtk( itk::RGBPixel< unsigned char >, 2 );
+cpPlugins_I_itk_vtk( itk::RGBPixel< unsigned short >, 2 );
+
+cpPlugins_I_itk_vtk( itk::RGBPixel< char >, 3 );
+cpPlugins_I_itk_vtk( itk::RGBPixel< short >, 3 );
+cpPlugins_I_itk_vtk( itk::RGBPixel< unsigned char >, 3 );
+cpPlugins_I_itk_vtk( itk::RGBPixel< unsigned short >, 3 );
+
+cpPlugins_I_itk_vtk( itk::RGBAPixel< char >, 2 );
+cpPlugins_I_itk_vtk( itk::RGBAPixel< short >, 2 );
+cpPlugins_I_itk_vtk( itk::RGBAPixel< unsigned char >, 2 );
+cpPlugins_I_itk_vtk( itk::RGBAPixel< unsigned short >, 2 );
+
+cpPlugins_I_itk_vtk( itk::RGBAPixel< char >, 3 );
+cpPlugins_I_itk_vtk( itk::RGBAPixel< short >, 3 );
+cpPlugins_I_itk_vtk( itk::RGBAPixel< unsigned char >, 3 );
+cpPlugins_I_itk_vtk( itk::RGBAPixel< unsigned short >, 3 );
+
+cpPlugins_I_itk_vtk_array( itk::Vector, float, 1, 1 );
+cpPlugins_I_itk_vtk_array( itk::Vector, double, 1, 1 );
+cpPlugins_I_itk_vtk_array( itk::Vector, float, 2, 2 );
+cpPlugins_I_itk_vtk_array( itk::Vector, double, 2, 2 );
+cpPlugins_I_itk_vtk_array( itk::Vector, float, 3, 3 );
+cpPlugins_I_itk_vtk_array( itk::Vector, double, 3, 3 );
+
+cpPlugins_I_itk_vtk_array( itk::Point, float, 1, 1 );
+cpPlugins_I_itk_vtk_array( itk::Point, double, 1, 1 );
+cpPlugins_I_itk_vtk_array( itk::Point, float, 2, 2 );
+cpPlugins_I_itk_vtk_array( itk::Point, double, 2, 2 );
+cpPlugins_I_itk_vtk_array( itk::Point, float, 3, 3 );
+cpPlugins_I_itk_vtk_array( itk::Point, double, 3, 3 );
+
+cpPlugins_I_itk_vtk_array( itk::CovariantVector, float, 1, 1 );
+cpPlugins_I_itk_vtk_array( itk::CovariantVector, double, 1, 1 );
+cpPlugins_I_itk_vtk_array( itk::CovariantVector, float, 2, 2 );
+cpPlugins_I_itk_vtk_array( itk::CovariantVector, double, 2, 2 );
+cpPlugins_I_itk_vtk_array( itk::CovariantVector, float, 3, 3 );
+cpPlugins_I_itk_vtk_array( itk::CovariantVector, double, 3, 3 );
+
+cpPlugins_I_itk_vtk_array( itk::SymmetricSecondRankTensor, float, 1, 1 );
+cpPlugins_I_itk_vtk_array( itk::SymmetricSecondRankTensor, double, 1, 1 );
+cpPlugins_I_itk_vtk_array( itk::SymmetricSecondRankTensor, float, 2, 2 );
+cpPlugins_I_itk_vtk_array( itk::SymmetricSecondRankTensor, double, 2, 2 );
+cpPlugins_I_itk_vtk_array( itk::SymmetricSecondRankTensor, float, 3, 3 );
+cpPlugins_I_itk_vtk_array( itk::SymmetricSecondRankTensor, double, 3, 3 );
+
+cpPlugins_I_itk_vtk( itk::DiffusionTensor3D< float >, 3 );
+cpPlugins_I_itk_vtk( itk::DiffusionTensor3D< double >, 3 );
 
 // eof - $RCSfile$
index 603aca9d421f69b15991286a37156b02ea9f4450..38a5f14af0b02729b9298d1290265e586cb20a51 100644 (file)
@@ -350,4 +350,144 @@ GetValueAsRealList( std::vector< TReal >& lst, const TString& name ) const
       lst.push_back( TReal( std::atof( token.c_str( ) ) ) );
 }
 
+// -------------------------------------------------------------------------
+bool cpPlugins::Interface::Parameters::
+HasStringValue( const TString& name ) const
+{
+  TParameters::const_iterator pIt = this->m_Parameters.find( name );
+  if( pIt != this->m_Parameters.end( ) )
+    return( pIt->second.first == Self::String );
+  return( false );
+}
+
+// -------------------------------------------------------------------------
+bool cpPlugins::Interface::Parameters::
+HasBoolValue( const TString& name ) const
+{
+  TParameters::const_iterator pIt = this->m_Parameters.find( name );
+  if( pIt != this->m_Parameters.end( ) )
+    return( pIt->second.first == Self::Bool );
+  return( false );
+}
+
+// -------------------------------------------------------------------------
+bool cpPlugins::Interface::Parameters::
+HasIntValue( const TString& name ) const
+{
+  TParameters::const_iterator pIt = this->m_Parameters.find( name );
+  if( pIt != this->m_Parameters.end( ) )
+    return( pIt->second.first == Self::Int );
+  return( false );
+}
+
+// -------------------------------------------------------------------------
+bool cpPlugins::Interface::Parameters::
+HasUintValue( const TString& name ) const
+{
+  TParameters::const_iterator pIt = this->m_Parameters.find( name );
+  if( pIt != this->m_Parameters.end( ) )
+    return( pIt->second.first == Self::Uint );
+  return( false );
+}
+
+// -------------------------------------------------------------------------
+bool cpPlugins::Interface::Parameters::
+HasRealValue( const TString& name ) const
+{
+  TParameters::const_iterator pIt = this->m_Parameters.find( name );
+  if( pIt != this->m_Parameters.end( ) )
+    return( pIt->second.first == Self::Real );
+  return( false );
+}
+
+// -------------------------------------------------------------------------
+bool cpPlugins::Interface::Parameters::
+HasIndexValue( const TString& name ) const
+{
+  TParameters::const_iterator pIt = this->m_Parameters.find( name );
+  if( pIt != this->m_Parameters.end( ) )
+    return( pIt->second.first == Self::Index );
+  return( false );
+}
+
+// -------------------------------------------------------------------------
+bool cpPlugins::Interface::Parameters::
+HasPointValue( const TString& name ) const
+{
+  TParameters::const_iterator pIt = this->m_Parameters.find( name );
+  if( pIt != this->m_Parameters.end( ) )
+    return( pIt->second.first == Self::Point );
+  return( false );
+}
+
+// -------------------------------------------------------------------------
+bool cpPlugins::Interface::Parameters::
+HasStringListValue( const TString& name ) const
+{
+  TParameters::const_iterator pIt = this->m_Parameters.find( name );
+  if( pIt != this->m_Parameters.end( ) )
+    return( pIt->second.first == Self::StringList );
+  return( false );
+}
+
+// -------------------------------------------------------------------------
+bool cpPlugins::Interface::Parameters::
+HasBoolListValue( const TString& name ) const
+{
+  TParameters::const_iterator pIt = this->m_Parameters.find( name );
+  if( pIt != this->m_Parameters.end( ) )
+    return( pIt->second.first == Self::BoolList );
+  return( false );
+}
+
+// -------------------------------------------------------------------------
+bool cpPlugins::Interface::Parameters::
+HasIntListValue( const TString& name ) const
+{
+  TParameters::const_iterator pIt = this->m_Parameters.find( name );
+  if( pIt != this->m_Parameters.end( ) )
+    return( pIt->second.first == Self::IntList );
+  return( false );
+}
+
+// -------------------------------------------------------------------------
+bool cpPlugins::Interface::Parameters::
+HasUintListValue( const TString& name ) const
+{
+  TParameters::const_iterator pIt = this->m_Parameters.find( name );
+  if( pIt != this->m_Parameters.end( ) )
+    return( pIt->second.first == Self::UintList );
+  return( false );
+}
+
+// -------------------------------------------------------------------------
+bool cpPlugins::Interface::Parameters::
+HasRealListValue( const TString& name ) const
+{
+  TParameters::const_iterator pIt = this->m_Parameters.find( name );
+  if( pIt != this->m_Parameters.end( ) )
+    return( pIt->second.first == Self::RealList );
+  return( false );
+}
+
+// -------------------------------------------------------------------------
+bool cpPlugins::Interface::Parameters::
+HasIndexListValue( const TString& name ) const
+{
+  TParameters::const_iterator pIt = this->m_Parameters.find( name );
+  if( pIt != this->m_Parameters.end( ) )
+    return( pIt->second.first == Self::IndexList );
+  return( false );
+}
+
+// -------------------------------------------------------------------------
+bool cpPlugins::Interface::Parameters::
+HasPointListValue( const TString& name ) const
+{
+  TParameters::const_iterator pIt = this->m_Parameters.find( name );
+  if( pIt != this->m_Parameters.end( ) )
+    return( pIt->second.first == Self::PointList );
+  return( false );
+}
+
 // eof - $RCSfile$
index 1e840f4ed8b102e82c9608895ae567c0c78848f5..dbcf98c68a16c4c62073e95f19026f745dff582f 100644 (file)
@@ -119,6 +119,20 @@ namespace cpPlugins
         std::vector< P >& lst, const TString& name
         ) const;
 
+      bool HasStringValue( const TString& name ) const;
+      bool HasBoolValue( const TString& name ) const;
+      bool HasIntValue( const TString& name ) const;
+      bool HasUintValue( const TString& name ) const;
+      bool HasRealValue( const TString& name ) const;
+      bool HasIndexValue( const TString& name ) const;
+      bool HasPointValue( const TString& name ) const;
+      bool HasStringListValue( const TString& name ) const;
+      bool HasBoolListValue( const TString& name ) const;
+      bool HasIntListValue( const TString& name ) const;
+      bool HasUintListValue( const TString& name ) const;
+      bool HasRealListValue( const TString& name ) const;
+      bool HasIndexListValue( const TString& name ) const;
+      bool HasPointListValue( const TString& name ) const;
 
     protected:
       TParameters m_Parameters;
index 7cf63765c206464b05c7c12e37cc202ba751ff77..61ea66aa7b0f66b5be810341685535c034762edf 100644 (file)
@@ -6,6 +6,8 @@
 #include <cpPlugins/Interface/DataObject.h>
 #include <cpPlugins/Interface/Parameters.h>
 
+#include <cpPlugins/Interface/Image.h>
+
 #define ITK_MANUAL_INSTANTIATION
 #include <itkProcessObject.h>
 
@@ -47,11 +49,6 @@ namespace cpPlugins
       ProcessObject( );
       virtual ~ProcessObject( );
 
-      /* TODO
-         virtual itk::DataObject* _GetInput( unsigned int idx );
-         virtual void _SetOutput( unsigned int idx, itk::DataObject* dobj );
-      */
-
       template< class O >
         void _MakeOutput( unsigned int idx )
       {
@@ -81,6 +78,563 @@ namespace cpPlugins
 
 } // ecapseman
 
+// -------------------------------------------------------------------------
+#define cpPlugins_Image_Demangle_Methods( c )                           \
+  std::string _DemangleImageDimension( itk::DataObject* o );            \
+  std::string _DemangleImagePixel( unsigned int d, itk::DataObject* o );
+
+// -------------------------------------------------------------------------
+#define cpPlugins_Image_Demangle_Methods_Code( c, f )                   \
+  std::string c::_DemangleImageDimension( itk::DataObject* o )          \
+  {                                                                     \
+    std::string r = "";                                                 \
+    if( dynamic_cast< itk::ImageBase< 1 >* >( o ) != NULL )             \
+    {                                                                   \
+      cpPlugins_Image_Array_Demangle(                                   \
+        itk::Vector, float, 1, 1, o, f, r                               \
+        );                                                              \
+      else cpPlugins_Image_Array_Demangle(                              \
+        itk::Vector, double, 1, 1, o, f, r                              \
+        );                                                              \
+      else cpPlugins_Image_Array_Demangle(                              \
+        itk::Point, float, 1, 1, o, f, r                                \
+        );                                                              \
+      else cpPlugins_Image_Array_Demangle(                              \
+        itk::Point, double, 1, 1, o, f, r                               \
+        );                                                              \
+      else cpPlugins_Image_Array_Demangle(                              \
+        itk::CovariantVector, float, 1, 1, o, f, r                      \
+        );                                                              \
+      else cpPlugins_Image_Array_Demangle(                              \
+        itk::CovariantVector, double, 1, 1, o, f, r                     \
+        );                                                              \
+      else cpPlugins_Image_Array_Demangle(                              \
+        itk::SymmetricSecondRankTensor, float, 1, 1, o, f, r            \
+        );                                                              \
+      else cpPlugins_Image_Array_Demangle(                              \
+        itk::SymmetricSecondRankTensor, double, 1, 1, o, f, r           \
+        );                                                              \
+      else r = this->_DemangleImagePixel( 1, o );                       \
+    }                                                                   \
+    else if( dynamic_cast< itk::ImageBase< 2 >* >( o ) != NULL )        \
+    {                                                                   \
+      cpPlugins_Image_Demangle(                                         \
+        itk::RGBPixel< char >, 2, o, f, r                               \
+        );                                                              \
+      else cpPlugins_Image_Demangle(                                    \
+        itk::RGBPixel< short >, 2, o, f, r                              \
+        );                                                              \
+      else cpPlugins_Image_Demangle(                                    \
+        itk::RGBPixel< unsigned char >, 2, o, f, r                      \
+        );                                                              \
+      else cpPlugins_Image_Demangle(                                    \
+        itk::RGBPixel< unsigned short >, 2, o, f, r                     \
+        );                                                              \
+      else cpPlugins_Image_Demangle(                                    \
+        itk::RGBAPixel< char >, 2, o, f, r                              \
+        );                                                              \
+      else cpPlugins_Image_Demangle(                                    \
+        itk::RGBAPixel< short >, 2, o, f, r                             \
+        );                                                              \
+      else cpPlugins_Image_Demangle(                                    \
+        itk::RGBAPixel< unsigned char >, 2, o, f, r                     \
+        );                                                              \
+      else cpPlugins_Image_Demangle(                                    \
+        itk::RGBAPixel< unsigned short >, 2, o, f, r                    \
+        );                                                              \
+      else cpPlugins_Image_Array_Demangle(                              \
+        itk::Vector, float, 2, 2, o, f, r                               \
+        );                                                              \
+      else cpPlugins_Image_Array_Demangle(                              \
+        itk::Vector, double, 2, 2, o, f, r                              \
+        );                                                              \
+      else cpPlugins_Image_Array_Demangle(                              \
+        itk::Point, float, 2, 2, o, f, r                                \
+        );                                                              \
+      else cpPlugins_Image_Array_Demangle(                              \
+        itk::Point, double, 2, 2, o, f, r                               \
+        );                                                              \
+      else cpPlugins_Image_Array_Demangle(                              \
+        itk::CovariantVector, float, 2, 2, o, f, r                      \
+        );                                                              \
+      else cpPlugins_Image_Array_Demangle(                              \
+        itk::CovariantVector, double, 2, 2, o, f, r                     \
+        );                                                              \
+      else cpPlugins_Image_Array_Demangle(                              \
+        itk::SymmetricSecondRankTensor, float, 2, 2, o, f, r            \
+        );                                                              \
+      else cpPlugins_Image_Array_Demangle(                              \
+        itk::SymmetricSecondRankTensor, double, 2, 2, o, f, r           \
+        );                                                              \
+      else r = this->_DemangleImagePixel( 2, o );                       \
+    }                                                                   \
+    else if( dynamic_cast< itk::ImageBase< 3 >* >( o ) != NULL )        \
+    {                                                                   \
+      cpPlugins_Image_Demangle(                                         \
+        itk::RGBPixel< char >, 3, o, f, r                               \
+        );                                                              \
+      else cpPlugins_Image_Demangle(                                    \
+        itk::RGBPixel< short >, 3, o, f, r                              \
+        );                                                              \
+      else cpPlugins_Image_Demangle(                                    \
+        itk::RGBPixel< unsigned char >, 3, o, f, r                      \
+        );                                                              \
+      else cpPlugins_Image_Demangle(                                    \
+        itk::RGBPixel< unsigned short >, 3, o, f, r                     \
+        );                                                              \
+      else cpPlugins_Image_Demangle(                                    \
+        itk::RGBAPixel< char >, 3, o, f, r                              \
+        );                                                              \
+      else cpPlugins_Image_Demangle(                                    \
+        itk::RGBAPixel< short >, 3, o, f, r                             \
+        );                                                              \
+      else cpPlugins_Image_Demangle(                                    \
+        itk::RGBAPixel< unsigned char >, 3, o, f, r                     \
+        );                                                              \
+      else cpPlugins_Image_Demangle(                                    \
+        itk::RGBAPixel< unsigned short >, 3, o, f, r                    \
+        );                                                              \
+      else cpPlugins_Image_Array_Demangle(                              \
+        itk::Vector, float, 3, 3, o, f, r                               \
+        );                                                              \
+      else cpPlugins_Image_Array_Demangle(                              \
+        itk::Vector, double, 3, 3, o, f, r                              \
+        );                                                              \
+      else cpPlugins_Image_Array_Demangle(                              \
+        itk::Point, float, 3, 3, o, f, r                                \
+        );                                                              \
+      else cpPlugins_Image_Array_Demangle(                              \
+        itk::Point, double, 3, 3, o, f, r                               \
+        );                                                              \
+      else cpPlugins_Image_Array_Demangle(                              \
+        itk::CovariantVector, float, 3, 3, o, f, r                      \
+        );                                                              \
+      else cpPlugins_Image_Array_Demangle(                              \
+        itk::CovariantVector, double, 3, 3, o, f, r                     \
+        );                                                              \
+      else cpPlugins_Image_Array_Demangle(                              \
+        itk::SymmetricSecondRankTensor, float, 3, 3, o, f, r            \
+        );                                                              \
+      else cpPlugins_Image_Array_Demangle(                              \
+        itk::SymmetricSecondRankTensor, double, 3, 3, o, f, r           \
+        );                                                              \
+      else cpPlugins_Image_Demangle(                                    \
+        itk::DiffusionTensor3D< float >, 3, o, f, r                     \
+        );                                                              \
+      else cpPlugins_Image_Demangle(                                    \
+        itk::DiffusionTensor3D< double >, 3, o, f, r                    \
+        );                                                              \
+      else r = this->_DemangleImagePixel( 3, o );                       \
+    }                                                                   \
+    else if( dynamic_cast< itk::ImageBase< 4 >* >( o ) != NULL )        \
+    {                                                                   \
+      cpPlugins_Image_Demangle(                                         \
+        itk::RGBPixel< char >, 4, o, f, r                               \
+        );                                                              \
+      else cpPlugins_Image_Demangle(                                    \
+        itk::RGBPixel< short >, 4, o, f, r                              \
+        );                                                              \
+      else cpPlugins_Image_Demangle(                                    \
+        itk::RGBPixel< unsigned char >, 4, o, f, r                      \
+        );                                                              \
+      else cpPlugins_Image_Demangle(                                    \
+        itk::RGBPixel< unsigned short >, 4, o, f, r                     \
+        );                                                              \
+      else cpPlugins_Image_Demangle(                                    \
+        itk::RGBAPixel< char >, 4, o, f, r                              \
+        );                                                              \
+      else cpPlugins_Image_Demangle(                                    \
+        itk::RGBAPixel< short >, 4, o, f, r                             \
+        );                                                              \
+      else cpPlugins_Image_Demangle(                                    \
+        itk::RGBAPixel< unsigned char >, 4, o, f, r                     \
+        );                                                              \
+      else cpPlugins_Image_Demangle(                                    \
+        itk::RGBAPixel< unsigned short >, 4, o, f, r                    \
+        );                                                              \
+      else cpPlugins_Image_Array_Demangle(                              \
+        itk::Vector, float, 4, 4, o, f, r                               \
+        );                                                              \
+      else cpPlugins_Image_Array_Demangle(                              \
+        itk::Vector, double, 4, 4, o, f, r                              \
+        );                                                              \
+      else cpPlugins_Image_Array_Demangle(                              \
+        itk::Point, float, 4, 4, o, f, r                                \
+        );                                                              \
+      else cpPlugins_Image_Array_Demangle(                              \
+        itk::Point, double, 4, 4, o, f, r                               \
+        );                                                              \
+      else cpPlugins_Image_Array_Demangle(                              \
+        itk::CovariantVector, float, 4, 4, o, f, r                      \
+        );                                                              \
+      else cpPlugins_Image_Array_Demangle(                              \
+        itk::CovariantVector, double, 4, 4, o, f, r                     \
+        );                                                              \
+      else cpPlugins_Image_Array_Demangle(                              \
+        itk::SymmetricSecondRankTensor, float, 4, 4, o, f, r            \
+        );                                                              \
+      else cpPlugins_Image_Array_Demangle(                              \
+        itk::SymmetricSecondRankTensor, double, 4, 4, o, f, r           \
+        );                                                              \
+      else r = this->_DemangleImagePixel( 4, o );                       \
+    }                                                                   \
+    else                                                                \
+      r =                                                               \
+        std::string( #c ) +                                             \
+        std::string( ": Image dimension not supported." );              \
+    return( r );                                                        \
+  }                                                                     \
+  std::string c::_DemangleImagePixel(                                   \
+    unsigned int d, itk::DataObject* o                                  \
+    )                                                                   \
+  {                                                                     \
+    std::string r = "";                                                 \
+    if( d == 1 )                                                        \
+    {                                                                   \
+      cpPlugins_Image_Demangle(                                         \
+        char, 1, o, f, r                                                \
+        );                                                              \
+      else cpPlugins_Image_Demangle(                                    \
+        short, 1, o, f, r                                               \
+        );                                                              \
+      else cpPlugins_Image_Demangle(                                    \
+        int, 1, o, f, r                                                 \
+        );                                                              \
+      else cpPlugins_Image_Demangle(                                    \
+        long, 1, o, f, r                                                \
+        );                                                              \
+      else cpPlugins_Image_Demangle(                                    \
+        unsigned char, 1, o, f, r                                       \
+        );                                                              \
+      else cpPlugins_Image_Demangle(                                    \
+        unsigned short, 1, o, f, r                                      \
+        );                                                              \
+      else cpPlugins_Image_Demangle(                                    \
+        unsigned int, 1, o, f, r                                        \
+        );                                                              \
+      else cpPlugins_Image_Demangle(                                    \
+        unsigned long, 1, o, f, r                                       \
+        );                                                              \
+      else cpPlugins_Image_Demangle(                                    \
+        float, 1, o, f, r                                               \
+        );                                                              \
+      else cpPlugins_Image_Demangle(                                    \
+        double, 1, o, f, r                                              \
+        );                                                              \
+      else cpPlugins_Image_Demangle(                                    \
+        std::complex< float >, 1, o, f, r                               \
+        );                                                              \
+      else cpPlugins_Image_Demangle(                                    \
+        std::complex< double >, 1, o, f, r                              \
+        );                                                              \
+      else cpPlugins_Image_Demangle(                                    \
+        itk::Offset< 1 >, 1, o, f, r                                    \
+        );                                                              \
+      else r = std::string( #c ) + std::string( ": Image type." );      \
+    }                                                                   \
+    else if( d == 2 )                                                   \
+    {                                                                   \
+      cpPlugins_Image_Demangle(                                         \
+        char, 2, o, f, r                                                \
+        );                                                              \
+      else cpPlugins_Image_Demangle(                                    \
+        short, 2, o, f, r                                               \
+        );                                                              \
+      else cpPlugins_Image_Demangle(                                    \
+        int, 2, o, f, r                                                 \
+        );                                                              \
+      else cpPlugins_Image_Demangle(                                    \
+        long, 2, o, f, r                                                \
+        );                                                              \
+      else cpPlugins_Image_Demangle(                                    \
+        unsigned char, 2, o, f, r                                       \
+        );                                                              \
+      else cpPlugins_Image_Demangle(                                    \
+        unsigned short, 2, o, f, r                                      \
+        );                                                              \
+      else cpPlugins_Image_Demangle(                                    \
+        unsigned int, 2, o, f, r                                        \
+        );                                                              \
+      else cpPlugins_Image_Demangle(                                    \
+        unsigned long, 2, o, f, r                                       \
+        );                                                              \
+      else cpPlugins_Image_Demangle(                                    \
+        float, 2, o, f, r                                               \
+        );                                                              \
+      else cpPlugins_Image_Demangle(                                    \
+        double, 2, o, f, r                                              \
+        );                                                              \
+      else cpPlugins_Image_Demangle(                                    \
+        std::complex< float >, 2, o, f, r                               \
+        );                                                              \
+      else cpPlugins_Image_Demangle(                                    \
+        std::complex< double >, 2, o, f, r                              \
+        );                                                              \
+      else cpPlugins_Image_Demangle(                                    \
+        itk::Offset< 2 >, 2, o, f, r                                    \
+        );                                                              \
+      else r = std::string( #c ) + std::string( ": Image type." );      \
+    }                                                                   \
+    else if( d == 3 )                                                   \
+    {                                                                   \
+      cpPlugins_Image_Demangle(                                         \
+        char, 3, o, f, r                                                \
+        );                                                              \
+      else cpPlugins_Image_Demangle(                                    \
+        short, 3, o, f, r                                               \
+        );                                                              \
+      else cpPlugins_Image_Demangle(                                    \
+        int, 3, o, f, r                                                 \
+        );                                                              \
+      else cpPlugins_Image_Demangle(                                    \
+        long, 3, o, f, r                                                \
+        );                                                              \
+      else cpPlugins_Image_Demangle(                                    \
+        unsigned char, 3, o, f, r                                       \
+        );                                                              \
+      else cpPlugins_Image_Demangle(                                    \
+        unsigned short, 3, o, f, r                                      \
+        );                                                              \
+      else cpPlugins_Image_Demangle(                                    \
+        unsigned int, 3, o, f, r                                        \
+        );                                                              \
+      else cpPlugins_Image_Demangle(                                    \
+        unsigned long, 3, o, f, r                                       \
+        );                                                              \
+      else cpPlugins_Image_Demangle(                                    \
+        float, 3, o, f, r                                               \
+        );                                                              \
+      else cpPlugins_Image_Demangle(                                    \
+        double, 3, o, f, r                                              \
+        );                                                              \
+      else cpPlugins_Image_Demangle(                                    \
+        std::complex< float >, 3, o, f, r                               \
+        );                                                              \
+      else cpPlugins_Image_Demangle(                                    \
+        std::complex< double >, 3, o, f, r                              \
+        );                                                              \
+      else cpPlugins_Image_Demangle(                                    \
+        itk::Offset< 3 >, 3, o, f, r                                    \
+        );                                                              \
+      else r = std::string( #c ) + std::string( ": Image type." );      \
+    }                                                                   \
+    else if( d == 4 )                                                   \
+    {                                                                   \
+      cpPlugins_Image_Demangle(                                         \
+        char, 4, o, f, r                                                \
+        );                                                              \
+      else cpPlugins_Image_Demangle(                                    \
+        short, 4, o, f, r                                               \
+        );                                                              \
+      else cpPlugins_Image_Demangle(                                    \
+        int, 4, o, f, r                                                 \
+        );                                                              \
+      else cpPlugins_Image_Demangle(                                    \
+        long, 4, o, f, r                                                \
+        );                                                              \
+      else cpPlugins_Image_Demangle(                                    \
+        unsigned char, 4, o, f, r                                       \
+        );                                                              \
+      else cpPlugins_Image_Demangle(                                    \
+        unsigned short, 4, o, f, r                                      \
+        );                                                              \
+      else cpPlugins_Image_Demangle(                                    \
+        unsigned int, 4, o, f, r                                        \
+        );                                                              \
+      else cpPlugins_Image_Demangle(                                    \
+        unsigned long, 4, o, f, r                                       \
+        );                                                              \
+      else cpPlugins_Image_Demangle(                                    \
+        float, 4, o, f, r                                               \
+        );                                                              \
+      else cpPlugins_Image_Demangle(                                    \
+        double, 4, o, f, r                                              \
+        );                                                              \
+      else cpPlugins_Image_Demangle(                                    \
+        std::complex< float >, 4, o, f, r                               \
+        );                                                              \
+      else cpPlugins_Image_Demangle(                                    \
+        std::complex< double >, 4, o, f, r                              \
+        );                                                              \
+      else cpPlugins_Image_Demangle(                                    \
+        itk::Offset< 4 >, 4, o, f, r                                    \
+        );                                                              \
+      else r = std::string( #c ) + std::string( ": Image type." );      \
+    }                                                                   \
+    else                                                                \
+      r =                                                               \
+        std::string( #c ) +                                             \
+        std::string( ": Image dimension not supported." );              \
+    return( r );                                                        \
+  }
+
+// -------------------------------------------------------------------------
+#define cpPlugins_Image_Demangle_Methods_Code_Only_Scalars( c, f )      \
+  std::string c::_DemangleImageDimension( itk::DataObject* o )          \
+  {                                                                     \
+    std::string r = "";                                                 \
+    if( dynamic_cast< itk::ImageBase< 1 >* >( o ) != NULL )             \
+      r = this->_DemangleImagePixel( 1, o );                            \
+    else if( dynamic_cast< itk::ImageBase< 2 >* >( o ) != NULL )        \
+      r = this->_DemangleImagePixel( 2, o );                            \
+    else if( dynamic_cast< itk::ImageBase< 3 >* >( o ) != NULL )        \
+      r = this->_DemangleImagePixel( 3, o );                            \
+    else if( dynamic_cast< itk::ImageBase< 4 >* >( o ) != NULL )        \
+      r = this->_DemangleImagePixel( 4, o );                            \
+    else                                                                \
+      r =                                                               \
+        std::string( #c ) +                                             \
+        std::string( ": Image dimension not supported." );              \
+    return( r );                                                        \
+  }                                                                     \
+  std::string c::_DemangleImagePixel(                                   \
+    unsigned int d, itk::DataObject* o                                  \
+    )                                                                   \
+  {                                                                     \
+    std::string r = "";                                                 \
+    if( d == 1 )                                                        \
+    {                                                                   \
+      cpPlugins_Image_Demangle(                                         \
+        char, 1, o, f, r                                                \
+        );                                                              \
+      else cpPlugins_Image_Demangle(                                    \
+        short, 1, o, f, r                                               \
+        );                                                              \
+      else cpPlugins_Image_Demangle(                                    \
+        int, 1, o, f, r                                                 \
+        );                                                              \
+      else cpPlugins_Image_Demangle(                                    \
+        long, 1, o, f, r                                                \
+        );                                                              \
+      else cpPlugins_Image_Demangle(                                    \
+        unsigned char, 1, o, f, r                                       \
+        );                                                              \
+      else cpPlugins_Image_Demangle(                                    \
+        unsigned short, 1, o, f, r                                      \
+        );                                                              \
+      else cpPlugins_Image_Demangle(                                    \
+        unsigned int, 1, o, f, r                                        \
+        );                                                              \
+      else cpPlugins_Image_Demangle(                                    \
+        unsigned long, 1, o, f, r                                       \
+        );                                                              \
+      else cpPlugins_Image_Demangle(                                    \
+        float, 1, o, f, r                                               \
+        );                                                              \
+      else cpPlugins_Image_Demangle(                                    \
+        double, 1, o, f, r                                              \
+        );                                                              \
+      else r = std::string( #c ) + std::string( ": Image type." );      \
+    }                                                                   \
+    else if( d == 2 )                                                   \
+    {                                                                   \
+      cpPlugins_Image_Demangle(                                         \
+        char, 2, o, f, r                                                \
+        );                                                              \
+      else cpPlugins_Image_Demangle(                                    \
+        short, 2, o, f, r                                               \
+        );                                                              \
+      else cpPlugins_Image_Demangle(                                    \
+        int, 2, o, f, r                                                 \
+        );                                                              \
+      else cpPlugins_Image_Demangle(                                    \
+        long, 2, o, f, r                                                \
+        );                                                              \
+      else cpPlugins_Image_Demangle(                                    \
+        unsigned char, 2, o, f, r                                       \
+        );                                                              \
+      else cpPlugins_Image_Demangle(                                    \
+        unsigned short, 2, o, f, r                                      \
+        );                                                              \
+      else cpPlugins_Image_Demangle(                                    \
+        unsigned int, 2, o, f, r                                        \
+        );                                                              \
+      else cpPlugins_Image_Demangle(                                    \
+        unsigned long, 2, o, f, r                                       \
+        );                                                              \
+      else cpPlugins_Image_Demangle(                                    \
+        float, 2, o, f, r                                               \
+        );                                                              \
+      else cpPlugins_Image_Demangle(                                    \
+        double, 2, o, f, r                                              \
+        );                                                              \
+      else r = std::string( #c ) + std::string( ": Image type." );      \
+    }                                                                   \
+    else if( d == 3 )                                                   \
+    {                                                                   \
+      cpPlugins_Image_Demangle(                                         \
+        char, 3, o, f, r                                                \
+        );                                                              \
+      else cpPlugins_Image_Demangle(                                    \
+        short, 3, o, f, r                                               \
+        );                                                              \
+      else cpPlugins_Image_Demangle(                                    \
+        int, 3, o, f, r                                                 \
+        );                                                              \
+      else cpPlugins_Image_Demangle(                                    \
+        long, 3, o, f, r                                                \
+        );                                                              \
+      else cpPlugins_Image_Demangle(                                    \
+        unsigned char, 3, o, f, r                                       \
+        );                                                              \
+      else cpPlugins_Image_Demangle(                                    \
+        unsigned short, 3, o, f, r                                      \
+        );                                                              \
+      else cpPlugins_Image_Demangle(                                    \
+        unsigned int, 3, o, f, r                                        \
+        );                                                              \
+      else cpPlugins_Image_Demangle(                                    \
+        unsigned long, 3, o, f, r                                       \
+        );                                                              \
+      else cpPlugins_Image_Demangle(                                    \
+        float, 3, o, f, r                                               \
+        );                                                              \
+      else cpPlugins_Image_Demangle(                                    \
+        double, 3, o, f, r                                              \
+        );                                                              \
+      else r = std::string( #c ) + std::string( ": Image type." );      \
+    }                                                                   \
+    else if( d == 4 )                                                   \
+    {                                                                   \
+      cpPlugins_Image_Demangle(                                         \
+        char, 4, o, f, r                                                \
+        );                                                              \
+      else cpPlugins_Image_Demangle(                                    \
+        short, 4, o, f, r                                               \
+        );                                                              \
+      else cpPlugins_Image_Demangle(                                    \
+        int, 4, o, f, r                                                 \
+        );                                                              \
+      else cpPlugins_Image_Demangle(                                    \
+        long, 4, o, f, r                                                \
+        );                                                              \
+      else cpPlugins_Image_Demangle(                                    \
+        unsigned char, 4, o, f, r                                       \
+        );                                                              \
+      else cpPlugins_Image_Demangle(                                    \
+        unsigned short, 4, o, f, r                                      \
+        );                                                              \
+      else cpPlugins_Image_Demangle(                                    \
+        unsigned int, 4, o, f, r                                        \
+        );                                                              \
+      else cpPlugins_Image_Demangle(                                    \
+        unsigned long, 4, o, f, r                                       \
+        );                                                              \
+      else cpPlugins_Image_Demangle(                                    \
+        float, 4, o, f, r                                               \
+        );                                                              \
+      else cpPlugins_Image_Demangle(                                    \
+        double, 4, o, f, r                                              \
+        );                                                              \
+      else r = std::string( #c ) + std::string( ": Image type." );      \
+    }                                                                   \
+    else                                                                \
+      r =                                                               \
+        std::string( #c ) +                                             \
+        std::string( ": Image dimension not supported." );              \
+    return( r );                                                        \
+  }
+
 #endif // __CPPLUGINS__INTERFACE__PROCESSOBJECT__H__
 
 // eof - $RCSfile$
index 09b4b5ae682f1b412b1c23b640dc7cac6fb86e6c..ccb6f7599c97c54d9f0956a3f3eaf77017af7d8e 100644 (file)
@@ -19,6 +19,7 @@ SET(
   MeshReader.h
   MeshWriter.h
   MarchingCubes.h
+  OtsuThresholdImageFilter.h
   )
 SET(
   LIB_SOURCES_CXX
@@ -28,6 +29,7 @@ SET(
   MeshReader.cxx
   MeshWriter.cxx
   MarchingCubes.cxx
+  OtsuThresholdImageFilter.cxx
   )
 
 ## =====================
index 44f225741497ce400febd8854dac99cd5883a050..fdf703da8bfea4df93f1b2ab82830ad61d41cbf2 100644 (file)
@@ -4,11 +4,11 @@
 #include <cpPlugins/Plugins/MeshReader.h>
 #include <cpPlugins/Plugins/MeshWriter.h>
 #include <cpPlugins/Plugins/MarchingCubes.h>
+#include <cpPlugins/Plugins/OtsuThresholdImageFilter.h>
 
 /*
   #include <cpPlugins/Plugins/ImageSeriesReader.h>
   #include <cpPlugins/Plugins/MeshReader.h>
-  #include <cpPlugins/Plugins/PolyDataReader.h>
   #include <cpPlugins/Plugins/RGBImageToHSVChannelsFilter.h>
   #include <cpPlugins/Plugins/RGBImageToYPbPrChannelsFilter.h>
 */
@@ -24,13 +24,15 @@ bool connect( pluma::Host& host )
   host.add( new MeshReaderProvider( ) );
   host.add( new MeshWriterProvider( ) );
   host.add( new MarchingCubesProvider( ) );
-/*
-  host.add( new ImageSeriesReaderProvider( ) );
-  host.add( new MeshReaderProvider( ) );
-  host.add( new PolyDataReaderProvider( ) );
-  host.add( new RGBImageToHSVChannelsFilterProvider( ) );
-  host.add( new RGBImageToYPbPrChannelsFilterProvider( ) );
-*/
+  host.add( new OtsuThresholdImageFilterProvider( ) );
+
+  /*
+    host.add( new ImageSeriesReaderProvider( ) );
+    host.add( new MeshReaderProvider( ) );
+    host.add( new PolyDataReaderProvider( ) );
+    host.add( new RGBImageToHSVChannelsFilterProvider( ) );
+    host.add( new RGBImageToYPbPrChannelsFilterProvider( ) );
+  */
   return( true );
 }
 
index 2d1ae0493887d5cc8976be55a595eea88b118420..24399718c9e5477f8c6a45fb6461abe95e5e0570 100644 (file)
@@ -1,11 +1,21 @@
 #include <cpPlugins/Plugins/ImageReader.h>
 #include <cpPlugins/Interface/Image.h>
 
+#include <complex>
 #include <set>
 
-#undef ITK_MANUAL_INSTANTIATION
+#define ITK_MANUAL_INSTANTIATION
 #include <itkImage.h>
+
+#include <itkCovariantVector.h>
+#include <itkDiffusionTensor3D.h>
+#include <itkPoint.h>
 #include <itkRGBPixel.h>
+#include <itkRGBAPixel.h>
+#include <itkSymmetricSecondRankTensor.h>
+#include <itkVector.h>
+
+#undef ITK_MANUAL_INSTANTIATION
 #include <itkImageFileReader.h>
 #include <itkImageSeriesReader.h>
 
@@ -59,8 +69,9 @@ _GenerateData( )
         case 1: r = this->_GD0< 1 >( io, names ); break;
         case 2: r = this->_GD0< 2 >( io, names ); break;
         case 3: r = this->_GD0< 3 >( io, names ); break;
+        case 4: r = this->_GD0< 4 >( io, names ); break;
         default:
-          r = "ImageReader: Image dimension not supported.";
+          r = "ImageReader: Single image dimension not supported.";
           break;
         } // hctiws
       }
@@ -70,8 +81,9 @@ _GenerateData( )
         {
         case 1: r = this->_GD0< 2 >( io, names ); break;
         case 2: r = this->_GD0< 3 >( io, names ); break;
+        case 3: r = this->_GD0< 4 >( io, names ); break;
         default:
-          r = "ImageReader: Image dimension not supported.";
+          r = "ImageReader: Multiple images dimension not supported.";
           break;
         } // hctiws
 
@@ -90,105 +102,319 @@ template< unsigned int D >
 std::string cpPlugins::Plugins::ImageReader::
 _GD0( itk::ImageIOBase* io, const TStringList& names )
 {
+  itk::ImageIOBase::IOComponentType ct = io->GetComponentType( );
+  itk::ImageIOBase::IOPixelType pt = io->GetPixelType( );
   std::string r = "";
-  switch( io->GetComponentType( ) )
+
+  if( pt == itk::ImageIOBase::SCALAR )
   {
-  case itk::ImageIOBase::UCHAR:
-    r = this->_GD1< unsigned char, D >( io, names );
-    break;
-  case itk::ImageIOBase::CHAR:
-    r = this->_GD1< char, D >( io, names );
-    break;
-  case itk::ImageIOBase::USHORT:
-    r = this->_GD1< unsigned short, D >( io, names );
-    break;
-  case itk::ImageIOBase::SHORT:
-    r = this->_GD1< short, D >( io, names );
-    break;
-  case itk::ImageIOBase::UINT:
-    r = this->_GD1< unsigned int, D >( io, names );
-    break;
-  case itk::ImageIOBase::INT:
-    r = this->_GD1< int, D >( io, names );
-    break;
-  case itk::ImageIOBase::ULONG:
-    r = this->_GD1< unsigned long, D >( io, names );
-    break;
-  case itk::ImageIOBase::LONG:
-    r = this->_GD1< long, D >( io, names );
-    break;
-  case itk::ImageIOBase::FLOAT:
-    r = this->_GD1< float, D >( io, names );
-    break;
-  case itk::ImageIOBase::DOUBLE:
-    r = this->_GD1< double, D >( io, names );
-    break;
-  default:
-    r = "ImageReader: Atomic pixel type not supported.";
-    break;
-  } // hctiws
-  return( r );
-}
+    switch( ct )
+    {
+    case itk::ImageIOBase::UCHAR:
+      r = this->_RealGD< unsigned char, D >( names );
+      break;
+    case itk::ImageIOBase::CHAR:
+      r = this->_RealGD< char, D >( names );
+      break;
+    case itk::ImageIOBase::USHORT:
+      r = this->_RealGD< unsigned short, D >( names );
+      break;
+    case itk::ImageIOBase::SHORT:
+      r = this->_RealGD< short, D >( names );
+      break;
+    case itk::ImageIOBase::UINT:
+      r = this->_RealGD< unsigned int, D >( names );
+      break;
+    case itk::ImageIOBase::INT:
+      r = this->_RealGD< int, D >( names );
+      break;
+    case itk::ImageIOBase::ULONG:
+      r = this->_RealGD< unsigned long, D >( names );
+      break;
+    case itk::ImageIOBase::LONG:
+      r = this->_RealGD< long, D >( names );
+      break;
+    case itk::ImageIOBase::FLOAT:
+      r = this->_RealGD< float, D >( names );
+      break;
+    case itk::ImageIOBase::DOUBLE:
+      r = this->_RealGD< double, D >( names );
+      break;
+    default:
+      r = "ImageReader: Scalar pixel type not supported.";
+      break;
+    } // hctiws
+  }
+  else if( pt == itk::ImageIOBase::RGB )
+  {
+    if( D == 2 )
+    {
+      switch( ct )
+      {
+      case itk::ImageIOBase::UCHAR:
+        r = this->_RealGD< itk::RGBPixel< unsigned char >, 2 >( names );
+        break;
+      case itk::ImageIOBase::CHAR:
+        r = this->_RealGD< itk::RGBPixel< char >, 2 >( names );
+        break;
+      case itk::ImageIOBase::USHORT:
+        r = this->_RealGD< itk::RGBPixel< unsigned short >, 2 >( names );
+        break;
+      case itk::ImageIOBase::SHORT:
+        r = this->_RealGD< itk::RGBPixel< short >, 2 >( names );
+        break;
+      default:
+        r = "ImageReader: Scalar pixel type not supported.";
+        break;
+      } // hctiws
+    }
+    else if( D == 3 )
+    {
+      switch( ct )
+      {
+      case itk::ImageIOBase::UCHAR:
+        r = this->_RealGD< itk::RGBPixel< unsigned char >, 3 >( names );
+        break;
+      case itk::ImageIOBase::CHAR:
+        r = this->_RealGD< itk::RGBPixel< char >, 3 >( names );
+        break;
+      case itk::ImageIOBase::USHORT:
+        r = this->_RealGD< itk::RGBPixel< unsigned short >, 3 >( names );
+        break;
+      case itk::ImageIOBase::SHORT:
+        r = this->_RealGD< itk::RGBPixel< short >, 3 >( names );
+        break;
+      default:
+        r = "ImageReader: Scalar pixel type not supported.";
+        break;
+      } // hctiws
+    }
+    else if( D == 4 )
+    {
+      switch( ct )
+      {
+      case itk::ImageIOBase::UCHAR:
+        r = this->_RealGD< itk::RGBPixel< unsigned char >, 4 >( names );
+        break;
+      case itk::ImageIOBase::CHAR:
+        r = this->_RealGD< itk::RGBPixel< char >, 4 >( names );
+        break;
+      case itk::ImageIOBase::USHORT:
+        r = this->_RealGD< itk::RGBPixel< unsigned short >, 4 >( names );
+        break;
+      case itk::ImageIOBase::SHORT:
+        r = this->_RealGD< itk::RGBPixel< short >, 4 >( names );
+        break;
+      default:
+        r = "ImageReader: Scalar pixel type not supported.";
+        break;
+      } // hctiws
 
-// -------------------------------------------------------------------------
-template< class P, unsigned int D >
-std::string cpPlugins::Plugins::ImageReader::
-_GD1( itk::ImageIOBase* io, const TStringList& names )
-{
-  std::string r = "";
-  switch( io->GetPixelType( ) )
+    } // fi
+  }
+  else if( pt == itk::ImageIOBase::RGBA )
+  {
+    if( D == 2 )
+    {
+      switch( ct )
+      {
+      case itk::ImageIOBase::UCHAR:
+        r = this->_RealGD< itk::RGBAPixel< unsigned char >, 2 >( names );
+        break;
+      case itk::ImageIOBase::CHAR:
+        r = this->_RealGD< itk::RGBAPixel< char >, 2 >( names );
+        break;
+      case itk::ImageIOBase::USHORT:
+        r = this->_RealGD< itk::RGBAPixel< unsigned short >, 2 >( names );
+        break;
+      case itk::ImageIOBase::SHORT:
+        r = this->_RealGD< itk::RGBAPixel< short >, 2 >( names );
+        break;
+      default:
+        r = "ImageReader: Scalar pixel type not supported.";
+        break;
+      } // hctiws
+    }
+    else if( D == 3 )
+    {
+      switch( ct )
+      {
+      case itk::ImageIOBase::UCHAR:
+        r = this->_RealGD< itk::RGBAPixel< unsigned char >, 3 >( names );
+        break;
+      case itk::ImageIOBase::CHAR:
+        r = this->_RealGD< itk::RGBAPixel< char >, 3 >( names );
+        break;
+      case itk::ImageIOBase::USHORT:
+        r = this->_RealGD< itk::RGBAPixel< unsigned short >, 3 >( names );
+        break;
+      case itk::ImageIOBase::SHORT:
+        r = this->_RealGD< itk::RGBAPixel< short >, 3 >( names );
+        break;
+      default:
+        r = "ImageReader: Scalar pixel type not supported.";
+        break;
+      } // hctiws
+    }
+    else if( D == 4 )
+    {
+      switch( ct )
+      {
+      case itk::ImageIOBase::UCHAR:
+        r = this->_RealGD< itk::RGBAPixel< unsigned char >, 4 >( names );
+        break;
+      case itk::ImageIOBase::CHAR:
+        r = this->_RealGD< itk::RGBAPixel< char >, 4 >( names );
+        break;
+      case itk::ImageIOBase::USHORT:
+        r = this->_RealGD< itk::RGBAPixel< unsigned short >, 4 >( names );
+        break;
+      case itk::ImageIOBase::SHORT:
+        r = this->_RealGD< itk::RGBAPixel< short >, 4 >( names );
+        break;
+      default:
+        r = "ImageReader: Scalar pixel type not supported.";
+        break;
+      } // hctiws
+
+    } // fi
+  }
+  else if( pt == itk::ImageIOBase::OFFSET )
+  {
+    switch( D )
+    {
+    case 1:
+      r = this->_RealGD< itk::Offset< 1 >, 1 >( names );
+      break;
+    case 2:
+      r = this->_RealGD< itk::Offset< 2 >, 2 >( names );
+      break;
+    case 3:
+      r = this->_RealGD< itk::Offset< 3 >, 3 >( names );
+      break;
+    case 4:
+      r = this->_RealGD< itk::Offset< 4 >, 4 >( names );
+      break;
+    default:
+      r = "ImageReader: Offset pixel dimension not supported.";
+      break;
+    } // hctiws
+  }
+  else if( pt == itk::ImageIOBase::VECTOR )
+  {
+    switch( ct )
+    {
+    case itk::ImageIOBase::FLOAT:
+      r = this->_RealGD< itk::Vector< float, D >, D >( names );
+      break;
+    case itk::ImageIOBase::DOUBLE:
+      r = this->_RealGD< itk::Vector< double, D >, D >( names );
+      break;
+    default:
+      r = "ImageReader: Vector type not supported.";
+      break;
+    } // hctiws
+  }
+  else if( pt == itk::ImageIOBase::POINT )
   {
-  case itk::ImageIOBase::SCALAR:
-    r = this->_GD2< P, D >( names );
-    break;
-  case itk::ImageIOBase::RGB:
-    r = this->_GD2< itk::RGBPixel< P >, D >( names );
-    break;
-  case itk::ImageIOBase::RGBA:
-    r = this->_GD2< itk::RGBAPixel< P >, D >( names );
-    break;
-    /* TODO
-       case itk::ImageIOBase::OFFSET:
-       r = this->_GD2< itk::Offset< P >, D >( names );
-       break;
-       case itk::ImageIOBase::VECTOR:
-       r = this->_GD2< P, D >( names );
-       break;
-       case itk::ImageIOBase::POINT:
-       r = this->_GD2< P, D >( names );
-       break;
-       case itk::ImageIOBase::COVARIANTVECTOR:
-       r = this->_GD2< P, D >( names );
-       break;
-       case itk::ImageIOBase::SYMMETRICSECONDRANKTENSOR:
-       r = this->_GD2< P, D >( names );
-       break;
-       case itk::ImageIOBase::DIFFUSIONTENSOR3D:
-       r = this->_GD2< P, D >( names );
-       break;
-    */
-    /* TODO
-       case itk::ImageIOBase::COMPLEX:
-       r = this->_GD2< std::complex< P >, D >( names );
-       break;
-       case itk::ImageIOBase::FIXEDARRAY:
-       r = this->_GD2< P, D >( names );
-       break;
-       case itk::ImageIOBase::MATRIX:
-       r = this->_GD2< P, D >( names );
-       break;
-    */
-  default:
-    r = "ImageReader: Pixel type not supported.";
-    break;
-  } // hctiws
+    switch( ct )
+    {
+    case itk::ImageIOBase::FLOAT:
+      r = this->_RealGD< itk::Point< float, D >, D >( names );
+      break;
+    case itk::ImageIOBase::DOUBLE:
+      r = this->_RealGD< itk::Point< double, D >, D >( names );
+      break;
+    default:
+      r = "ImageReader: Point type not supported.";
+      break;
+    } // hctiws
+  }
+  else if( pt == itk::ImageIOBase::COVARIANTVECTOR )
+  {
+    switch( ct )
+    {
+    case itk::ImageIOBase::FLOAT:
+      r = this->_RealGD< itk::CovariantVector< float, D >, D >( names );
+      break;
+    case itk::ImageIOBase::DOUBLE:
+      r = this->_RealGD< itk::CovariantVector< double, D >, D >( names );
+      break;
+    default:
+      r = "ImageReader: Vector type not supported.";
+      break;
+    } // hctiws
+  }
+  else if( pt == itk::ImageIOBase::SYMMETRICSECONDRANKTENSOR )
+  {
+    switch( ct )
+    {
+    case itk::ImageIOBase::FLOAT:
+      r =
+        this->_RealGD< itk::SymmetricSecondRankTensor< float, D >, D >(
+          names
+          );
+      break;
+    case itk::ImageIOBase::DOUBLE:
+      r =
+        this->_RealGD< itk::SymmetricSecondRankTensor< double, D >, D >(
+          names
+          );
+      break;
+    default:
+      r = "ImageReader: Vector type not supported.";
+      break;
+    } // hctiws
+  }
+  else if( pt == itk::ImageIOBase::DIFFUSIONTENSOR3D )
+  {
+    if( D == 3 )
+    {
+      switch( ct )
+      {
+      case itk::ImageIOBase::FLOAT:
+        r = this->_RealGD< itk::DiffusionTensor3D< float >, 3 >( names );
+        break;
+      case itk::ImageIOBase::DOUBLE:
+        r = this->_RealGD< itk::DiffusionTensor3D< double >, 3 >( names );
+        break;
+      default:
+        r = "ImageReader: Diffusion tensor type not supported.";
+        break;
+      } // hctiws
+    }
+    else
+      r = "ImageReader: Diffusion tensor dimension not supported.";
+  }
+  else if( pt == itk::ImageIOBase::COMPLEX )
+  {
+    switch( ct )
+    {
+    case itk::ImageIOBase::FLOAT:
+      r = this->_RealGD< std::complex< float >, D >( names );
+      break;
+    case itk::ImageIOBase::DOUBLE:
+      r = this->_RealGD< std::complex< double >, D >( names );
+      break;
+    default:
+      r = "ImageReader: Complex type not supported.";
+      break;
+    } // hctiws
+  }
+  else
+    r = "ImageReader: Image pixel type not yet supported.";
+  /* TODO
+     itk::ImageIOBase::FIXEDARRAY
+     itk::ImageIOBase::MATRIX
+  */
+
   return( r );
 }
 
 // -------------------------------------------------------------------------
 template< class P, unsigned int D >
 std::string cpPlugins::Plugins::ImageReader::
-_GD2( const TStringList& names )
+_RealGD( const TStringList& names )
 {
   typedef itk::Image< P, D > _I;
 
index 07aeebaec6ef8c63415baae0d8d317e7d31a2e6a..682e8054ec575bb7dca632032f9141bff8c59ef7 100644 (file)
@@ -42,10 +42,7 @@ namespace cpPlugins
         std::string _GD0( itk::ImageIOBase* io, const TStringList& names );
 
       template< class P, unsigned int D >
-        std::string _GD1( itk::ImageIOBase* io, const TStringList& names );
-
-      template< class P, unsigned int D >
-        std::string _GD2( const TStringList& names );
+        std::string _RealGD( const TStringList& names );
 
     private:
       // Purposely not implemented
index 9c99f2c8490ee2c5bcedb72a80423519fc176e8c..176e9f663ee9197aaabb01bfdd5423a936f6fd3f 100644 (file)
@@ -1,26 +1,20 @@
 #include <cpPlugins/Plugins/ImageWriter.h>
 
-#undef ITK_MANUAL_INSTANTIATION
-#include <itkImage.h>
-#include <itkRGBPixel.h>
-#include <itkImageFileWriter.h>
+#include <complex>
 
-// -------------------------------------------------------------------------
-#define cpPlugins_ImageWriter_Dimension( r, d, i, f )                \
-  if( dynamic_cast< itk::ImageBase< d >* >( i ) != NULL )            \
-    r = this->f< d >( i )
+#define ITK_MANUAL_INSTANTIATION
+#include <itkImage.h>
 
-// -------------------------------------------------------------------------
-#define cpPlugins_ImageWriter_Pixel( r, p, d, i, f )                    \
-  if( dynamic_cast< itk::Image< p, d >* >( i ) != NULL )                \
-    r = this->f< p, d >( i )
+#include <itkCovariantVector.h>
+#include <itkDiffusionTensor3D.h>
+#include <itkPoint.h>
+#include <itkRGBPixel.h>
+#include <itkRGBAPixel.h>
+#include <itkSymmetricSecondRankTensor.h>
+#include <itkVector.h>
 
-// -------------------------------------------------------------------------
-#define cpPlugins_ImageWriter_RGB( r, p, d, i, f )                      \
-  if(                                                                   \
-    dynamic_cast< itk::Image< itk::RGBPixel< p >, d >* >( i ) != NULL   \
-    )                                                                   \
-    r = this->f< itk::RGBPixel< p >, d >( i )
+#undef ITK_MANUAL_INSTANTIATION
+#include <itkImageFileWriter.h>
 
 // -------------------------------------------------------------------------
 cpPlugins::Plugins::ImageWriter::
@@ -47,50 +41,24 @@ std::string cpPlugins::Plugins::ImageWriter::
 _GenerateData( )
 {
   itk::DataObject* i = this->m_Inputs[ 0 ]->GetITKDataObject( );
-
-  std::string r = "ImageWriter: Image dimension not supported.";
-  cpPlugins_ImageWriter_Dimension     ( r, 1, i, _GD0 );
-  else cpPlugins_ImageWriter_Dimension( r, 2, i, _GD0 );
-  else cpPlugins_ImageWriter_Dimension( r, 3, i, _GD0 );
-  return( r );
+  return( this->_DemangleImageDimension( i ) );
 }
 
 // -------------------------------------------------------------------------
-template< unsigned int D >
-std::string cpPlugins::Plugins::ImageWriter::
-_GD0( itk::DataObject* i )
+namespace cpPlugins
 {
-  std::string r = "ImageWriter: Image pixel type not supported";
-  cpPlugins_ImageWriter_Pixel     ( r, char          , D, i, _GD1 );
-  else cpPlugins_ImageWriter_Pixel( r, short         , D, i, _GD1 );
-  else cpPlugins_ImageWriter_Pixel( r, int           , D, i, _GD1 );
-  else cpPlugins_ImageWriter_Pixel( r, long          , D, i, _GD1 );
-  else cpPlugins_ImageWriter_Pixel( r, unsigned char , D, i, _GD1 );
-  else cpPlugins_ImageWriter_Pixel( r, unsigned short, D, i, _GD1 );
-  else cpPlugins_ImageWriter_Pixel( r, unsigned int  , D, i, _GD1 );
-  else cpPlugins_ImageWriter_Pixel( r, unsigned long , D, i, _GD1 );
-  else cpPlugins_ImageWriter_Pixel( r, float         , D, i, _GD1 );
-  else cpPlugins_ImageWriter_Pixel( r, double        , D, i, _GD1 );
-  else cpPlugins_ImageWriter_RGB  ( r, char          , D, i, _GD1 );
-  else cpPlugins_ImageWriter_RGB  ( r, short         , D, i, _GD1 );
-  else cpPlugins_ImageWriter_RGB  ( r, int           , D, i, _GD1 );
-  else cpPlugins_ImageWriter_RGB  ( r, long          , D, i, _GD1 );
-  else cpPlugins_ImageWriter_RGB  ( r, unsigned char , D, i, _GD1 );
-  else cpPlugins_ImageWriter_RGB  ( r, unsigned short, D, i, _GD1 );
-  else cpPlugins_ImageWriter_RGB  ( r, unsigned int  , D, i, _GD1 );
-  else cpPlugins_ImageWriter_RGB  ( r, unsigned long , D, i, _GD1 );
-  else cpPlugins_ImageWriter_RGB  ( r, float         , D, i, _GD1 );
-  else cpPlugins_ImageWriter_RGB  ( r, double        , D, i, _GD1 );
-  return( r );
+  namespace Plugins
+  {
+    cpPlugins_Image_Demangle_Methods_Code( ImageWriter, _RealGD );
+  }
 }
 
 // -------------------------------------------------------------------------
-template< class P, unsigned int D >
+template< class I >
 std::string cpPlugins::Plugins::ImageWriter::
-_GD1( itk::DataObject* i )
+_RealGD( itk::DataObject* image )
 {
-  typedef itk::Image< P, D > _I;
-  typedef itk::ImageFileWriter< _I > _W;
+  typedef itk::ImageFileWriter< I > _W;
 
   // Get filename
   using namespace cpPlugins::Interface;
@@ -105,7 +73,7 @@ _GD1( itk::DataObject* i )
 
   } // fi
   writer->SetFileName( fname );
-  writer->SetInput( dynamic_cast< _I* >( i ) );
+  writer->SetInput( dynamic_cast< I* >( image ) );
   try
   {
     writer->Update( );
index dc8d5da04539ac4e54619ce5489e9ba6f424c551..e6e8220349bf9fd00f216db6e1867de86faf1f92 100644 (file)
@@ -29,11 +29,10 @@ namespace cpPlugins
 
       virtual std::string _GenerateData( );
 
-      template< unsigned int D >
-        std::string _GD0( itk::DataObject* i );
+      cpPlugins_Image_Demangle_Methods( ImageWriter );
 
-      template< class P, unsigned int D >
-        std::string _GD1( itk::DataObject* i );
+      template< class I >
+        std::string _RealGD( itk::DataObject* image );
 
     private:
       // Purposely not implemented
diff --git a/lib/cpPlugins/Plugins/OtsuThresholdImageFilter.cxx b/lib/cpPlugins/Plugins/OtsuThresholdImageFilter.cxx
new file mode 100644 (file)
index 0000000..38228b9
--- /dev/null
@@ -0,0 +1,128 @@
+#include <cpPlugins/Plugins/OtsuThresholdImageFilter.h>
+#include <cpPlugins/Interface/Image.h>
+
+#include <complex>
+
+#define ITK_MANUAL_INSTANTIATION
+#include <itkImage.h>
+
+#include <itkCovariantVector.h>
+#include <itkDiffusionTensor3D.h>
+#include <itkPoint.h>
+#include <itkRGBPixel.h>
+#include <itkRGBAPixel.h>
+#include <itkSymmetricSecondRankTensor.h>
+#include <itkVector.h>
+
+#undef ITK_MANUAL_INSTANTIATION
+#include <itkOtsuThresholdImageFilter.h>
+
+// -------------------------------------------------------------------------
+cpPlugins::Plugins::OtsuThresholdImageFilter::
+OtsuThresholdImageFilter( )
+  : Superclass( )
+{
+  this->m_ClassName = "cpPlugins::OtsuThresholdImageFilter";
+  this->m_ClassCategory = "ImageToImageFilter";
+  this->SetNumberOfInputs( 1 );
+  this->SetNumberOfOutputs( 1 );
+  this->_MakeOutput< cpPlugins::Interface::Image >( 0 );
+
+  using namespace cpPlugins::Interface;
+  this->m_DefaultParameters.Configure( Parameters::Uint, "NumberOfHistogramBins" );
+  this->m_DefaultParameters.Configure( Parameters::Real, "InsideValue" );
+  this->m_DefaultParameters.Configure( Parameters::Real, "OutsideValue" );
+  this->m_Parameters = this->m_DefaultParameters;
+}
+
+// -------------------------------------------------------------------------
+cpPlugins::Plugins::OtsuThresholdImageFilter::
+~OtsuThresholdImageFilter( )
+{
+}
+
+// -------------------------------------------------------------------------
+std::string cpPlugins::Plugins::OtsuThresholdImageFilter::
+_GenerateData( )
+{
+  itk::DataObject* i = this->m_Inputs[ 0 ]->GetITKDataObject( );
+  return( this->_DemangleImageDimension( i ) );
+}
+
+// -------------------------------------------------------------------------
+namespace cpPlugins
+{
+  namespace Plugins
+  {
+    cpPlugins_Image_Demangle_Methods_Code_Only_Scalars(
+      OtsuThresholdImageFilter, _DemangleInput
+      );
+  }
+}
+
+// -------------------------------------------------------------------------
+template< class I >
+std::string cpPlugins::Plugins::OtsuThresholdImageFilter::
+_DemangleInput( itk::DataObject* image )
+{
+  if( this->m_Parameters.HasStringValue( "OutputType" ) )
+  {
+    std::string output_type = this->m_Parameters.GetValueAsString( "OutputType" );
+    std::string r = "";
+    if( output_type == "char" )
+      r = this->_RealGD< I, itk::Image< char, I::ImageDimension > >( image );
+    else if( output_type == "uchar" )
+      r = this->_RealGD< I, itk::Image< unsigned char, I::ImageDimension > >( image );
+    else if( output_type == "short" )
+      r = this->_RealGD< I, itk::Image< short, I::ImageDimension > >( image );
+    else if( output_type == "ushort" )
+      r = this->_RealGD< I, itk::Image< unsigned short, I::ImageDimension > >( image );
+    else if( output_type == "int" )
+      r = this->_RealGD< I, itk::Image< int, I::ImageDimension > >( image );
+    else if( output_type == "uint" )
+      r = this->_RealGD< I, itk::Image< unsigned int, I::ImageDimension > >( image );
+    else if( output_type == "long" )
+      r = this->_RealGD< I, itk::Image< long, I::ImageDimension > >( image );
+    else if( output_type == "ulong" )
+      r = this->_RealGD< I, itk::Image< unsigned long, I::ImageDimension > >( image );
+    else if( output_type == "float" )
+      r = this->_RealGD< I, itk::Image< float, I::ImageDimension > >( image );
+    else if( output_type == "double" )
+      r = this->_RealGD< I, itk::Image< double, I::ImageDimension > >( image );
+    else
+      r = "OtsuThresholdImageFilter: Invalid output type.";
+  }
+  else
+    return( this->_RealGD< I, I >( image ) );
+}
+
+// -------------------------------------------------------------------------
+template< class I, class O >
+std::string cpPlugins::Plugins::OtsuThresholdImageFilter::
+_RealGD( itk::DataObject* image )
+{
+  typedef itk::OtsuThresholdImageFilter< I, O > _F;
+  typedef typename O::PixelType _OP;
+
+  unsigned int bins = this->m_Parameters.GetValueAsUint( "NumberOfHistogramBins" );
+  _OP in = _OP( this->m_Parameters.GetValueAsReal( "InsideValue" ) );
+  _OP out = _OP( this->m_Parameters.GetValueAsReal( "OutsideValue" ) );
+
+  _F* filter = dynamic_cast< _F* >( this->m_RealProcessObject.GetPointer( ) );
+  if( filter == NULL )
+  {
+    this->m_RealProcessObject = _F::New( );
+    filter = dynamic_cast< _F* >( this->m_RealProcessObject.GetPointer( ) );
+
+  } // fi
+  filter->SetInput( dynamic_cast< I* >( image ) );
+  filter->SetNumberOfHistogramBins( bins );
+  filter->SetInsideValue( in );
+  filter->SetOutsideValue( out );
+  filter->Update( );
+  this->m_Outputs[ 0 ]->SetITKDataObject( filter->GetOutput( ) );
+  
+  return( "" );
+}
+
+// eof - $RCSfile$
diff --git a/lib/cpPlugins/Plugins/OtsuThresholdImageFilter.h b/lib/cpPlugins/Plugins/OtsuThresholdImageFilter.h
new file mode 100644 (file)
index 0000000..07c9b75
--- /dev/null
@@ -0,0 +1,55 @@
+#ifndef __CPPLUGINS__PLUGINS__OTSUTHRESHOLDIMAGEFILTER__H__
+#define __CPPLUGINS__PLUGINS__OTSUTHRESHOLDIMAGEFILTER__H__
+
+#include <cpPlugins/Plugins/cpPlugins_Export.h>
+#include <cpPlugins/Interface/ImageToImageFilter.h>
+
+namespace cpPlugins
+{
+  namespace Plugins
+  {
+    /**
+     */
+    class cpPlugins_EXPORT OtsuThresholdImageFilter
+      : public cpPlugins::Interface::ImageToImageFilter
+    {
+    public:
+      typedef OtsuThresholdImageFilter                 Self;
+      typedef cpPlugins::Interface::ImageToImageFilter Superclass;
+      typedef itk::SmartPointer< Self >                Pointer;
+      typedef itk::SmartPointer< const Self >          ConstPointer;
+
+    public:
+      itkNewMacro( Self );
+      itkTypeMacro( OtsuThresholdImageFilter, cpPluginsInterfaceImageToImageFilter );
+
+    protected:
+      OtsuThresholdImageFilter( );
+      virtual ~OtsuThresholdImageFilter( );
+
+      virtual std::string _GenerateData( );
+
+      cpPlugins_Image_Demangle_Methods( OtsuThresholdImageFilter );
+
+      template< class I >
+        std::string _DemangleInput( itk::DataObject* image );
+
+      template< class I, class O >
+        std::string _RealGD( itk::DataObject* image );
+
+    private:
+      // Purposely not implemented
+      OtsuThresholdImageFilter( const Self& );
+      Self& operator=( const Self& );
+    };
+
+    // ---------------------------------------------------------------------
+    CPPLUGINS_INHERIT_PROVIDER( OtsuThresholdImageFilter );
+
+  } // ecapseman
+
+} // ecapseman
+
+#endif // __CPPLUGINS__PLUGINS__OTSUTHRESHOLDIMAGEFILTER__H__
+
+// eof - $RCSfile$
diff --git a/lib/cpPlugins/Plugins/PolyDataReader.cxx b/lib/cpPlugins/Plugins/PolyDataReader.cxx
deleted file mode 100644 (file)
index 95576ac..0000000
+++ /dev/null
@@ -1,73 +0,0 @@
-#include <cpPlugins/Plugins/PolyDataReader.h>
-#include <cpPlugins/Interface/PolyData.h>
-
-#include <vtkErrorCode.h>
-#include <vtkPolyDataReader.h>
-
-// -------------------------------------------------------------------------
-std::string cpPlugins::Plugins::PolyDataReader::
-GetClassName( ) const
-{
-  return( "cpPlugins::Plugins::PolyDataReader" );
-}
-
-// -------------------------------------------------------------------------
-cpPlugins::Plugins::PolyDataReader::
-PolyDataReader( )
-  : Superclass( )
-{
-  this->SetNumberOfOutputs( 1 );
-  this->_MakeOutput< cpPlugins::Interface::PolyData >( 0 );
-
-  using namespace cpPlugins::Interface;
-  this->m_DefaultParameters.Configure( Parameters::String, "FileName" );
-  this->m_Parameters = this->m_DefaultParameters;
-}
-
-// -------------------------------------------------------------------------
-cpPlugins::Plugins::PolyDataReader::
-~PolyDataReader( )
-{
-}
-
-// -------------------------------------------------------------------------
-std::string cpPlugins::Plugins::PolyDataReader::
-_GenerateData( )
-{
-  // Get filename
-  using namespace cpPlugins::Interface;
-  Parameters::TString fname =
-    this->m_Parameters.GetValueAsString( "FileName" );
-
-  // Create a possible reader
-  vtkPolyDataReader* reader =
-    dynamic_cast< vtkPolyDataReader* >( this->m_Reader.GetPointer( ) );
-  if( reader == NULL )
-  {
-    this->m_Reader = vtkSmartPointer< vtkPolyDataReader >::New( );
-    reader =
-      dynamic_cast< vtkPolyDataReader* >( this->m_Reader.GetPointer( ) );
-
-  } // fi
-  reader->SetFileName( fname.c_str( ) );
-  reader->Update( );
-  unsigned long error = reader->GetErrorCode( );
-  if( error == vtkErrorCode::NoError )
-  {
-    if( this->m_Outputs[ 0 ].IsNotNull( ) )
-    {
-      cpPlugins::Interface::PolyData* pdata =
-        dynamic_cast< cpPlugins::Interface::PolyData* >(
-          this->m_Outputs[ 0 ].GetPointer( )
-          );
-      if( pdata != NULL )
-        pdata->SetRealDataObject( reader->GetOutput( ) );
-
-    } // fi
-    return( "" );
-  }
-  else
-    return( vtkErrorCode::GetStringFromErrorCode( error ) );
-}
-
-// eof - $RCSfile$
diff --git a/lib/cpPlugins/Plugins/PolyDataReader.h b/lib/cpPlugins/Plugins/PolyDataReader.h
deleted file mode 100644 (file)
index 106f9a6..0000000
+++ /dev/null
@@ -1,56 +0,0 @@
-#ifndef __CPPLUGINS__PLUGINS__POLYDATAREADER__H__
-#define __CPPLUGINS__PLUGINS__POLYDATAREADER__H__
-
-#include <cpPlugins/Plugins/cpPlugins_Export.h>
-#include <cpPlugins/Interface/PolyDataSource.h>
-
-#include <vtkAlgorithm.h>
-#include <vtkSmartPointer.h>
-
-namespace cpPlugins
-{
-  namespace Plugins
-  {
-    /**
-     */
-    class cpPlugins_EXPORT PolyDataReader
-      : public cpPlugins::Interface::PolyDataSource
-    {
-    public:
-      typedef PolyDataReader                       Self;
-      typedef cpPlugins::Interface::PolyDataSource Superclass;
-      typedef itk::SmartPointer< Self >            Pointer;
-      typedef itk::SmartPointer< const Self >      ConstPointer;
-
-    public:
-      itkNewMacro( Self );
-      itkTypeMacro( PolyDataReader, cpPluginsInterfacePolyDataSource );
-
-    public:
-      virtual std::string GetClassName( ) const;
-
-    protected:
-      PolyDataReader( );
-      virtual ~PolyDataReader( );
-
-      virtual std::string _GenerateData( );
-
-    private:
-      // Purposely not implemented
-      PolyDataReader( const Self& );
-      Self& operator=( const Self& );
-
-    protected:
-      vtkSmartPointer< vtkAlgorithm > m_Reader;
-    };
-
-    // ---------------------------------------------------------------------
-    CPPLUGINS_INHERIT_PROVIDER( PolyDataReader );
-
-  } // ecapseman
-
-} // ecapseman
-
-#endif // __CPPLUGINS__PLUGINS__POLYDATAREADER__H__
-
-// eof - $RCSfile$