]> Creatis software - cpPlugins.git/blobdiff - plugins/ITKRasterFilters/RasterImageFilter.cxx
Moved to version 1.0
[cpPlugins.git] / plugins / ITKRasterFilters / RasterImageFilter.cxx
diff --git a/plugins/ITKRasterFilters/RasterImageFilter.cxx b/plugins/ITKRasterFilters/RasterImageFilter.cxx
deleted file mode 100644 (file)
index 097566c..0000000
+++ /dev/null
@@ -1,160 +0,0 @@
-#include <ITKRasterFilters/RasterImageFilter.h>
-#include <cpInstances/DataObjects/Image.h>
-#include <cpInstances/DataObjects/Mesh.h>
-
-#include <vtkPolyData.h>
-#include <itkTriangleMeshToBinaryImageFilter.h>
-#include <cpExtensions/Algorithms/RasterContourFilter.h>
-
-// -------------------------------------------------------------------------
-cpPluginsITKRasterFilters::RasterImageFilter::
-RasterImageFilter( )
-  : Superclass( )
-{
-  typedef cpInstances::DataObjects::Mesh  _TMesh;
-  typedef cpInstances::DataObjects::Image _TImage;
-
-  this->_ConfigureInput< _TMesh >( "Input", true, false );
-  this->_ConfigureInput< _TImage >( "TemplateImage", false, false );
-  this->_ConfigureOutput< _TImage >( "Output" );
-
-  this->m_Parameters.ConfigureAsReal( "InsideValue", 1 );
-  this->m_Parameters.ConfigureAsReal( "OutsideValue", 0 );
-  this->m_Parameters.ConfigureAsScalarTypesChoices( "OutputPixelType" );
-}
-
-// -------------------------------------------------------------------------
-cpPluginsITKRasterFilters::RasterImageFilter::
-~RasterImageFilter( )
-{
-}
-
-// -------------------------------------------------------------------------
-void cpPluginsITKRasterFilters::RasterImageFilter::
-_GenerateData( )
-{
-  auto mesh = this->GetInputData< vtkPolyData >( "Input" );
-  double bounds[ 6 ];
-  mesh->GetBounds( bounds );
-  double zdiff = std::fabs( bounds[ 5 ] - bounds[ 4 ] );
-  if( zdiff > 1e-5 )
-  {
-    cpPlugins_Demangle_Mesh_Meshes_1(
-      this->GetInputData( "Input" ), _GD0_3D, 3
-      )
-      this->_Error( "Invalid input image dimension." );
-  }
-  else
-    this->_GD0_2D( mesh );
-}
-
-// -------------------------------------------------------------------------
-template< class _TMesh >
-void cpPluginsITKRasterFilters::RasterImageFilter::
-_GD0_2D( _TMesh* mesh )
-{
-  std::string p_type =
-    this->m_Parameters.GetSelectedChoice( "OutputPixelType" );
-  if( p_type == "char" ) this->_GD1_2D< _TMesh, char >( mesh );
-  else if( p_type == "short" ) this->_GD1_2D< _TMesh, short >( mesh );
-  else if( p_type == "int" ) this->_GD1_2D< _TMesh, int >( mesh );
-  else if( p_type == "long" ) this->_GD1_2D< _TMesh, long >( mesh );
-  else if( p_type == "uchar" ) this->_GD1_2D< _TMesh, unsigned char >( mesh );
-  else if( p_type == "ushort" ) this->_GD1_2D< _TMesh, unsigned short >( mesh );
-  else if( p_type == "uint" ) this->_GD1_2D< _TMesh, unsigned int >( mesh );
-  else if( p_type == "ulong" ) this->_GD1_2D< _TMesh, unsigned long >( mesh );
-  else if( p_type == "float" ) this->_GD1_2D< _TMesh, float >( mesh );
-  else if( p_type == "double" ) this->_GD1_2D< _TMesh, double >( mesh );
-}
-
-// -------------------------------------------------------------------------
-template< class _TMesh, class _TPixelType >
-void cpPluginsITKRasterFilters::RasterImageFilter::
-_GD1_2D( _TMesh* mesh )
-{
-  typedef itk::Image< _TPixelType, 2 > _TImage;
-  typedef typename _TImage::Superclass _TBaseImage;
-  typedef cpExtensions::Algorithms::RasterContourFilter< _TImage > _TFilter;
-
-  // Configure filter
-  _TFilter* filter = this->_CreateITK< _TFilter >( );
-  filter->SetInsideValue( this->m_Parameters.GetReal( "InsideValue" ) );
-  filter->SetOutsideValue( this->m_Parameters.GetReal( "OutsideValue" ) );
-  filter->SetTemplate( this->GetInputData< _TBaseImage >( "TemplateImage" ) );
-  filter->ClearPoints( );
-  for( unsigned long i = 0; i < mesh->GetNumberOfPoints( ); ++i )
-  {
-    double pnt[ 3 ];
-    mesh->GetPoint( i, pnt );
-    filter->AddPoint( pnt );
-
-  } // rof
-
-  // Execute and connect output
-  filter->Update( );
-  this->GetOutput( "Output" )->SetITK( filter->GetOutput( ) );
-}
-
-// -------------------------------------------------------------------------
-template< class _TMesh >
-void cpPluginsITKRasterFilters::RasterImageFilter::
-_GD0_3D( _TMesh* mesh )
-{
-  std::string p_type =
-    this->m_Parameters.GetSelectedChoice( "OutputPixelType" );
-  if( p_type == "char" ) this->_GD1_3D< _TMesh, char >( mesh );
-  else if( p_type == "short" ) this->_GD1_3D< _TMesh, short >( mesh );
-  else if( p_type == "int" ) this->_GD1_3D< _TMesh, int >( mesh );
-  else if( p_type == "long" ) this->_GD1_3D< _TMesh, long >( mesh );
-  else if( p_type == "uchar" ) this->_GD1_3D< _TMesh, unsigned char >( mesh );
-  else if( p_type == "ushort" ) this->_GD1_3D< _TMesh, unsigned short >( mesh );
-  else if( p_type == "uint" ) this->_GD1_3D< _TMesh, unsigned int >( mesh );
-  else if( p_type == "ulong" ) this->_GD1_3D< _TMesh, unsigned long >( mesh );
-  else if( p_type == "float" ) this->_GD1_3D< _TMesh, float >( mesh );
-  else if( p_type == "double" ) this->_GD1_3D< _TMesh, double >( mesh );
-}
-
-// -------------------------------------------------------------------------
-template< class _TMesh, class _TPixelType >
-void cpPluginsITKRasterFilters::RasterImageFilter::
-_GD1_3D( _TMesh* mesh )
-{
-  typedef itk::Image< _TPixelType, 3 > _TImage;
-  typedef typename _TImage::Superclass _TBaseImage;
-  typedef itk::TriangleMeshToBinaryImageFilter< _TMesh, _TImage > _TFilter;
-
-  // Create filter
-  _TFilter* filter = this->_CreateITK< _TFilter >( );
-
-  // Compute bounding box
-  typename _TImage::DirectionType direction;
-  typename _TImage::PointType origin;
-  typename _TImage::SizeType size;
-  typename _TImage::SpacingType spac;
-  auto t_image = this->GetInputData< _TBaseImage >( "TemplateImage" );
-  if( t_image == NULL )
-  {
-  }
-  else
-  {
-    direction = t_image->GetDirection( );
-    origin = t_image->GetOrigin( );
-    size = t_image->GetLargestPossibleRegion( ).GetSize( );
-    spac = t_image->GetSpacing( );
-
-  } // fi
-
-  // Configure filter
-  filter->SetDirection( direction );
-  filter->SetOrigin( origin );
-  filter->SetSize( size );
-  filter->SetSpacing( spac );
-  filter->SetInsideValue( this->m_Parameters.GetReal( "InsideValue" ) );
-  filter->SetOutsideValue( this->m_Parameters.GetReal( "OutsideValue" ) );
-
-  // Execute and connect output
-  filter->Update( );
-  this->GetOutput( "Output" )->SetITK( filter->GetOutput( ) );
-}
-
-// eof - $RCSfile$