#include <vtkImageData.h>
#include <vtkPolyData.h>
-/* TODO
- #include <vtkImageTracerWidget.h>
- #include <vtkSplineWidget.h>
- #include <vtkSmartPointer.h>
- #include <vtkGlyphSource2D.h>
- #include <vtkProp.h>
-*/
-
#endif // cpExtensions_QT4
//----------------------------------------------------------------------------
typedef cpPlugins::Interface::Workspace _TWorkspace;
_TWorkspace::Pointer ws = _TWorkspace::New( );
ws->PrintExecutionOn( );
+ ws->Load( argv[ 1 ] );
// Configure filters
- auto reader = ws->CreateFilter( "IO", "ImageReader", "reader" );
- auto widget = ws->CreateFilter( "Widgets", "SplineWidget", "spline" );
- ws->Connect( "reader", "spline", "Output", "Input" );
- auto params = reader->GetParameters( );
- for( int i = 1; i < argc; ++i )
- params->AddToOpenFileNameList( "FileNames", argv[ i ] );
+ /* TODO
+ auto reader = ws->CreateFilter( "IO", "ImageReader", "reader" );
+ auto widget = ws->CreateFilter( "Widgets", "SplineWidget", "spline" );
+ ws->Connect( "reader", "spline", "Output", "Input" );
+ auto params = reader->GetParameters( );
+ for( int i = 1; i < argc; ++i )
+ params->AddToOpenFileNameList( "FileNames", argv[ i ] );
+ */
+ auto reader = ws->GetFilter( "reader" );
+ auto spline = ws->GetFilter( "spline" );
+ auto seeds = ws->GetFilter( "seeds" );
+ auto axis = ws->GetFilter( "axis" );
// Execute reader
try
view.SetImage(
reader->GetOutputData< vtkImageData >( "Output" ), 2, "image"
);
- widget->AddInteractor( view.GetInteractor( ) );
- widget->Update( );
+ spline->AddInteractor( view.GetInteractor( ) );
+ spline->Update( );
+ seeds->AddInteractor( view.GetInteractor( ) );
+ seeds->Update( );
// Start application and show data
wnd.setCentralWidget( &view );
wnd.show( );
- int r = app.exec( );
- widget->Modified( );
- widget->Update( );
- widget->GetOutputData< vtkPolyData >( "Output" )->Print( std::cout );
- return( r );
+ app.exec( );
+ spline->Modified( );
+ spline->Update( );
+
+ wnd.show( );
+ app.exec( );
+
+ seeds->Modified( );
+ seeds->Update( );
+ axis->Update( );
+ // view.Add( axis->GetOutputData< vtkPolyData >( "Output" ) );
+ wnd.show( );
+ return( app.exec( ) );
+
+ // TODO: widget->GetOutputData< vtkPolyData >( "Output" )->Print( std::cout );
+
+ /*
+ auto raster = ws->CreateFilter( "MeshToImageFilters", "RasterMeshFilter", "raster" );
+ ws->Connect( "spline", "raster", "Output", "Input" );
+ ws->Connect( "reader", "raster", "Output", "Template" );
+ raster->Update( );
+ */
+
#else // cpExtensions_QT4
return( 0 );
#endif // cpExtensions_QT4
#include <cpPlugins/DataObjects/Image.h>
+#include <cpPlugins/DataObjects/Image.hxx>
// -------------------------------------------------------------------------
void cpPlugins::DataObjects::Image::
void cpPlugins::DataObjects::Image::
SetVTK( vtkObjectBase* o )
{
- this->Superclass::SetVTK( o );
- std::cerr << "Image: TODO this!!!!" << std::endl;
- std::exit( 1 );
+ vtkImageData* img = dynamic_cast< vtkImageData* >( img );
+ this->Superclass::SetVTK( img );
+ if( img == NULL )
+ {
+ this->m_ITK = NULL;
+ this->m_ITKvVTK = NULL;
+ this->Modified( );
+ return;
+
+ } // fi
+
+ // Connect both worlds
+ this->_VTK_2_ITK_0< unsigned char >( img );
+ /* TODO
+ switch( img->GetScalarType( ) )
+ {
+ case VTK_CHAR: this->_VTK_2_ITK_0< char >( img ); break;
+ case VTK_SHORT: this->_VTK_2_ITK_0< short >( img ); break;
+ case VTK_INT: this->_VTK_2_ITK_0< int >( img ); break;
+ case VTK_LONG: this->_VTK_2_ITK_0< long >( img ); break;
+ case VTK_UNSIGNED_CHAR: this->_VTK_2_ITK_0< unsigned char >( img ); break;
+ case VTK_UNSIGNED_SHORT: this->_VTK_2_ITK_0< unsigned short >( img ); break;
+ case VTK_UNSIGNED_INT: this->_VTK_2_ITK_0< unsigned int >( img ); break;
+ case VTK_UNSIGNED_LONG: this->_VTK_2_ITK_0< unsigned long >( img ); break;
+ case VTK_FLOAT: this->_VTK_2_ITK_0< float >( img ); break;
+ case VTK_DOUBLE: this->_VTK_2_ITK_0< double >( img ); break;
+ default:
+ {
+ this->m_ITK = NULL;
+ this->m_ITKvVTK = NULL;
+
+ }
+ } // hctiws
+ */
+ this->Modified( );
}
// -------------------------------------------------------------------------
template< class _TImage >
inline void _ITK_2_VTK_1( _TImage* image );
+ template< class _TPixel >
+ inline void _VTK_2_ITK_0( vtkImageData* image );
+
+ template< class _TPixel, unsigned int _VDim >
+ inline void _VTK_2_ITK_1( vtkImageData* image );
+
private:
// Purposely not implemented
Image( const Self& );
} // ecapseman
#include <cpPlugins/BaseObjects/Demangle.h>
-#include <cpPlugins/DataObjects/Image.hxx>
#endif // __cpPlugins__DataObjects__Image__h__
#define __cpPlugins__DataObjects__Image__hxx__
#include <itkImageToVTKImageFilter.h>
+#include <itkVTKImageToImageFilter.h>
#include <itkImageToVTKImageFilter.hxx>
+#include <itkVTKImageToImageFilter.hxx>
#include <itkVTKImageExport.hxx>
+#include <itkVTKImageImport.hxx>
// -------------------------------------------------------------------------
template< unsigned int _VDim >
this->m_VTK = f->GetOutput( );
}
+// -------------------------------------------------------------------------
+template< class _TPixel >
+void cpPlugins::DataObjects::Image::
+_VTK_2_ITK_0( vtkImageData* image )
+{
+ if( image->GetDataDimension( ) == 2 )
+ this->_VTK_2_ITK_1< _TPixel, 2 >( image );
+ else if( image->GetDataDimension( ) == 3 )
+ this->_VTK_2_ITK_1< _TPixel, 3 >( image );
+ else
+ {
+ this->m_ITK = NULL;
+ this->m_ITKvVTK = NULL;
+
+ } // fi
+}
+
+// -------------------------------------------------------------------------
+template< class _TPixel, unsigned int _VDim >
+void cpPlugins::DataObjects::Image::
+_VTK_2_ITK_1( vtkImageData* image )
+{
+ typedef itk::Image< _TPixel, _VDim > _TImage;
+ typedef itk::VTKImageToImageFilter< _TImage > _TFilter;
+ _TFilter* f = dynamic_cast< _TFilter* >( this->m_ITKvVTK.GetPointer( ) );
+
+ std::cout << typeid( _TImage ).name( ) << std::endl;
+
+ if( f == NULL )
+ {
+ typename _TFilter::Pointer nf = _TFilter::New( );
+ this->m_ITKvVTK = nf;
+ f = nf.GetPointer( );
+
+ } // fi
+ f->SetInput( image );
+ f->Update( );
+
+ // Keep object track
+ this->m_VTK = image;
+ this->m_ITK = f->GetOutput( );
+}
+
#endif // __cpPlugins__DataObjects__Image__hxx__
// eof - $RCSfile$
--- /dev/null
+#include <plugins/ImageMeshFilters/RasterMeshFilter.h>
+#include <cpPlugins/DataObjects/BoundingBox.h>
+#include <cpPlugins/DataObjects/Mesh.h>
+
+#include <vtkImageData.h>
+#include <vtkImageStencil.h>
+#include <vtkLinearExtrusionFilter.h>
+#include <vtkPolyDataToImageStencil.h>
+#include <vtkStripper.h>
+
+#include <itkTriangleMeshToBinaryImageFilter.h>
+#include <itkTriangleMeshToBinaryImageFilter.hxx>
+
+// -------------------------------------------------------------------------
+cpPluginsImageMeshFilters::RasterMeshFilter::
+RasterMeshFilter( )
+ : Superclass( )
+{
+ typedef cpPlugins::BaseObjects::DataObject _TDataObject;
+ typedef cpPlugins::DataObjects::Image _TImage;
+ typedef cpPlugins::DataObjects::Mesh _TMesh;
+
+ this->_ConfigureInput< _TMesh >( "Input", true, false );
+ this->_ConfigureInput< _TDataObject >( "Template", false, false );
+ this->_ConfigureOutput< _TImage >( "Output" );
+
+ this->m_Parameters.ConfigureAsUint( "InsideValue" );
+ this->m_Parameters.ConfigureAsUint( "OutsideValue" );
+ this->m_Parameters.ConfigureAsUint( "MinimumSize" );
+
+ this->m_Parameters.SetUint( "InsideValue", 1 );
+ this->m_Parameters.SetUint( "OutsideValue", 0 );
+ this->m_Parameters.SetUint( "MinimumSize", 100 );
+}
+
+// -------------------------------------------------------------------------
+cpPluginsImageMeshFilters::RasterMeshFilter::
+~RasterMeshFilter( )
+{
+}
+
+// -------------------------------------------------------------------------
+void cpPluginsImageMeshFilters::RasterMeshFilter::
+_GenerateData( )
+{
+ typedef itk::Mesh< float, 3 > _3F;
+ typedef itk::Mesh< double, 3 > _3D;
+
+ bool is_2d = false;
+ auto pd = this->GetInputData< vtkPolyData >( "Input" );
+ if( pd != NULL )
+ {
+ double bounds[ 6 ];
+ pd->GetBounds( bounds );
+ is_2d = ( bounds[ 4 ] == bounds[ 5 ] );
+
+ } // fi
+ if( !is_2d )
+ {
+ auto _3f = this->GetInputData< _3F >( "Input" );
+ auto _3d = this->GetInputData< _3D >( "Input" );
+ if ( _3f != NULL ) this->_GD0_3D( _3f );
+ else if( _3d != NULL ) this->_GD0_3D( _3d );
+ else this->_Error( "No valid input mesh." );
+ }
+ else
+ this->_GD0_2D( pd );
+}
+
+// -------------------------------------------------------------------------
+template< class _TMesh >
+void cpPluginsImageMeshFilters::RasterMeshFilter::
+_GD0_2D( _TMesh* mesh )
+{
+ typedef itk::ImageBase< 2 > _TImageBase;
+ typedef itk::Image< unsigned char, 2 > _TImage;
+ typedef cpPlugins::DataObjects::BoundingBox _TBB;
+ typedef typename _TImage::PointType _TPoint;
+
+ static const unsigned int PAD = 10;
+
+ _TImage::Pointer white = this->GetOutputData< _TImage >( "Output" );
+ if( white.IsNull( ) )
+ white = _TImage::New( );
+
+ // Get configuration values
+ typename _TImage::SpacingType spac;
+ typename _TImage::SizeType size;
+ typename _TImage::PointType origin;
+ typename _TImage::DirectionType direction;
+ typename _TImage::IndexType index;
+
+ auto in_bb = this->GetInput< _TBB >( "Template" );
+ auto in_im = this->GetInputData< _TImageBase >( "Template" );
+ if( in_im != NULL )
+ {
+ spac = in_im->GetSpacing( );
+ size = in_im->GetLargestPossibleRegion( ).GetSize( );
+ origin = in_im->GetOrigin( );
+ direction = in_im->GetDirection( );
+ index = in_im->GetLargestPossibleRegion( ).GetIndex( );
+ }
+ else
+ {
+ _TPoint minBB, maxBB;
+ if( in_bb != NULL )
+ {
+ minBB = in_bb->GetMinimum< _TPoint >( );
+ maxBB = in_bb->GetMaximum< _TPoint >( );
+ }
+ else
+ {
+ double bounds[ 6 ];
+ mesh->GetBounds( bounds );
+ minBB[ 0 ] = bounds[ 0 ];
+ minBB[ 1 ] = bounds[ 1 ];
+ maxBB[ 0 ] = bounds[ 2 ];
+ maxBB[ 1 ] = bounds[ 3 ];
+
+ } // fi
+
+ double lx = double( maxBB[ 0 ] - minBB[ 0 ] );
+ double ly = double( maxBB[ 1 ] - minBB[ 1 ] );
+ double lm = ( lx < ly )? lx: ly;
+
+ // Compute spacing
+ spac.Fill( lm / double( this->m_Parameters.GetUint( "MinimumSize" ) ) );
+
+ // Compute size
+ size[ 0 ] = ( unsigned long )( std::ceil( lx / spac[ 0 ] ) );
+ size[ 1 ] = ( unsigned long )( std::ceil( ly / spac[ 1 ] ) );
+
+ // ... add some padding pixels
+ size[ 0 ] += PAD;
+ size[ 1 ] += PAD;
+
+ // Set origin
+ origin = minBB;
+ origin[ 0 ] -= double( PAD >> 1 ) * spac[ 0 ];
+ origin[ 1 ] -= double( PAD >> 1 ) * spac[ 1 ];
+
+ // Remaining values
+ direction.SetIdentity( );
+ index.Fill( 0 );
+
+ } // fi
+
+ // Configure output image
+ _TImage::RegionType region;
+ region.SetSize( size );
+ region.SetIndex( index );
+ white->SetSpacing( spac );
+ white->SetRegions( region );
+ white->SetOrigin( origin );
+ white->SetDirection( direction );
+ white->Allocate( );
+ white->FillBuffer( this->m_Parameters.GetUint( "InsideValue" ) );
+ if( this->m_WhiteImage.IsNull( ) )
+ this->m_WhiteImage = TImage::New( );
+ this->m_WhiteImage->SetITK( white );
+ vtkImageData* white_vtk = this->m_WhiteImage->GetVTK< vtkImageData >( );
+
+ // Configure mini-pipeline
+ if( this->m_Stripper.GetPointer( ) == NULL )
+ this->m_Stripper = vtkSmartPointer< vtkStripper >::New( );
+ this->m_Stripper->SetInputData( mesh );
+ this->m_Stripper->Update( );
+
+ if( this->m_Extruder.GetPointer( ) == NULL )
+ this->m_Extruder = vtkSmartPointer< vtkLinearExtrusionFilter >::New( );
+ this->m_Extruder->SetInputConnection( this->m_Stripper->GetOutputPort( ) );
+ this->m_Extruder->SetScaleFactor( double( 1 ) );
+ this->m_Extruder->SetExtrusionTypeToNormalExtrusion( );
+ this->m_Extruder->SetVector( 0, 0, 1 );
+ this->m_Extruder->Update( );
+
+ if( this->m_PolyDataToStencil.GetPointer( ) == NULL )
+ this->m_PolyDataToStencil =
+ vtkSmartPointer< vtkPolyDataToImageStencil >::New( );
+ this->m_PolyDataToStencil->SetTolerance( 0 );
+ this->m_PolyDataToStencil->SetInputConnection( this->m_Extruder->GetOutputPort( ) );
+ this->m_PolyDataToStencil->SetOutputOrigin( white_vtk->GetOrigin( ) );
+ this->m_PolyDataToStencil->SetOutputSpacing( white_vtk->GetSpacing( ) );
+ this->m_PolyDataToStencil->SetOutputWholeExtent( white_vtk->GetExtent( ) );
+ this->m_PolyDataToStencil->Update( );
+
+ this->m_ImageStencil = this->_CreateVTK< vtkImageStencil >( );
+ this->m_ImageStencil->SetInputData( white_vtk );
+ this->m_ImageStencil->SetStencilConnection( this->m_PolyDataToStencil->GetOutputPort( ) );
+ this->m_ImageStencil->ReverseStencilOff( );
+ this->m_ImageStencil->SetBackgroundValue( this->m_Parameters.GetUint( "OutsideValue" ) );
+ this->m_ImageStencil->Update( );
+ this->GetOutput( "Output" )->SetVTK( this->m_ImageStencil->GetOutput( ) );
+}
+
+// -------------------------------------------------------------------------
+template< class _TMesh >
+void cpPluginsImageMeshFilters::RasterMeshFilter::
+_GD0_3D( _TMesh* mesh )
+{
+ typedef unsigned char _TPixel;
+ typedef cpPlugins::DataObjects::BoundingBox _TBB;
+ typedef itk::ImageBase< _TMesh::PointDimension > _TImageBase;
+ typedef itk::Image< _TPixel, _TMesh::PointDimension > _TImage;
+ typedef itk::TriangleMeshToBinaryImageFilter< _TMesh, _TImage > _TFilter;
+ typedef typename _TImage::PointType _TPoint;
+
+ static const unsigned int PAD = 10;
+
+ _TFilter* filter = this->_CreateITK< _TFilter >( );
+ this->m_WhiteImage = NULL;
+ this->m_Stripper = NULL;
+ this->m_Extruder = NULL;
+ this->m_PolyDataToStencil = NULL;
+ this->m_ImageStencil = NULL;
+
+ // Get configuration values
+ typename _TImage::SpacingType spac;
+ typename _TImage::SizeType size;
+ typename _TImage::PointType origin;
+ typename _TImage::DirectionType direction;
+ typename _TImage::IndexType index;
+
+ auto in_bb = this->GetInput< _TBB >( "Template" );
+ auto in_im = this->GetInputData< _TImageBase >( "Template" );
+ if( in_im != NULL )
+ {
+ spac = in_im->GetSpacing( );
+ size = in_im->GetLargestPossibleRegion( ).GetSize( );
+ origin = in_im->GetOrigin( );
+ direction = in_im->GetDirection( );
+ index = in_im->GetLargestPossibleRegion( ).GetIndex( );
+ }
+ else
+ {
+ _TPoint minBB, maxBB;
+ if( in_bb != NULL )
+ {
+ minBB = in_bb->GetMinimum< _TPoint >( );
+ maxBB = in_bb->GetMaximum< _TPoint >( );
+ }
+ else
+ {
+ auto bb = mesh->GetBoundingBox( );
+ minBB = bb->GetMinimum( );
+ maxBB = bb->GetMaximum( );
+
+ } // fi
+
+ double lx = double( maxBB[ 0 ] - minBB[ 0 ] );
+ double ly = double( maxBB[ 1 ] - minBB[ 1 ] );
+ double lz = double( maxBB[ 2 ] - minBB[ 2 ] );
+ double lm = ( lx < ly )? lx: ly;
+ lm = ( lm < lz )? lm: lz;
+
+ // Compute spacing
+ spac.Fill( lm / double( this->m_Parameters.GetUint( "MinimumSize" ) ) );
+
+ // Compute size
+ size[ 0 ] = ( unsigned long )( std::ceil( lx / spac[ 0 ] ) );
+ size[ 1 ] = ( unsigned long )( std::ceil( ly / spac[ 1 ] ) );
+ size[ 2 ] = ( unsigned long )( std::ceil( lz / spac[ 2 ] ) );
+
+ // ... add some padding pixels
+ size[ 0 ] += PAD;
+ size[ 1 ] += PAD;
+ size[ 2 ] += PAD;
+
+ // Set origin
+ origin = minBB;
+ origin[ 0 ] -= double( PAD >> 1 ) * spac[ 0 ];
+ origin[ 1 ] -= double( PAD >> 1 ) * spac[ 1 ];
+ origin[ 2 ] -= double( PAD >> 1 ) * spac[ 2 ];
+
+ // Remaining values
+ direction.SetIdentity( );
+ index.Fill( 0 );
+
+ } // fi
+
+ // Execute
+ filter->SetInput( mesh );
+ filter->SetSpacing( spac );
+ filter->SetSize( size );
+ filter->SetOrigin( origin );
+ filter->SetDirection( direction );
+ filter->SetIndex( index );
+ filter->SetInsideValue( this->m_Parameters.GetUint( "InsideValue" ) );
+ filter->SetOutsideValue( this->m_Parameters.GetUint( "OutsideValue" ) );
+ filter->Update( );
+ this->GetOutput( "Output" )->SetITK( filter->GetOutput( ) );
+}
+
+// eof - $RCSfile$
--- /dev/null
+#ifndef __cpPluginsImageMesh__RasterMeshFilter__h__
+#define __cpPluginsImageMesh__RasterMeshFilter__h__
+
+#include <plugins/cpPluginsImageMeshFilters_Export.h>
+#include <cpPlugins/BaseObjects/ProcessObject.h>
+#include <cpPlugins/DataObjects/Image.h>
+#include <vtkSmartPointer.h>
+
+// -------------------------------------------------------------------------
+class vtkStripper;
+class vtkLinearExtrusionFilter;
+class vtkPolyDataToImageStencil;
+class vtkImageStencil;
+
+// -------------------------------------------------------------------------
+namespace cpPluginsImageMeshFilters
+{
+ /**
+ */
+ class cpPluginsImageMeshFilters_EXPORT RasterMeshFilter
+ : public cpPlugins::BaseObjects::ProcessObject
+ {
+ cpPluginsObject(
+ RasterMeshFilter,
+ cpPlugins::BaseObjects::ProcessObject,
+ MeshToImageFilters
+ );
+
+ public:
+ typedef cpPlugins::DataObjects::Image TImage;
+
+ protected:
+ template< class _TMesh >
+ inline void _GD0_2D( _TMesh* mesh );
+
+ template< class _TMesh >
+ inline void _GD0_3D( _TMesh* mesh );
+
+ protected:
+ TImage::Pointer m_WhiteImage;
+ vtkSmartPointer< vtkStripper > m_Stripper;
+ vtkSmartPointer< vtkLinearExtrusionFilter > m_Extruder;
+ vtkSmartPointer< vtkPolyDataToImageStencil > m_PolyDataToStencil;
+ vtkSmartPointer< vtkImageStencil > m_ImageStencil;
+ };
+
+} // ecapseman
+
+#endif // __cpPluginsImageMesh__RasterMeshFilter__h__
+
+// eof - $RCSfile$
+++ /dev/null
-#include <plugins/ImageMeshFilters/TriangleMeshToBinaryImageFilter.h>
-#include <cpPlugins/DataObjects/BoundingBox.h>
-#include <cpPlugins/DataObjects/Image.h>
-#include <cpPlugins/DataObjects/Mesh.h>
-
-#include <itkTriangleMeshToBinaryImageFilter.h>
-#include <itkTriangleMeshToBinaryImageFilter.hxx>
-
-// -------------------------------------------------------------------------
-cpPluginsImageMeshFilters::TriangleMeshToBinaryImageFilter::
-TriangleMeshToBinaryImageFilter( )
- : Superclass( )
-{
- this->_ConfigureInput< cpPlugins::DataObjects::Mesh >( "Input", true, false );
- this->_ConfigureInput< cpPlugins::DataObjects::BoundingBox >( "BoundingBox", true, false );
- this->_ConfigureOutput< cpPlugins::DataObjects::Image >( "Output" );
-
- this->m_Parameters.ConfigureAsUint( "InsideValue" );
- this->m_Parameters.ConfigureAsUint( "OutsideValue" );
- this->m_Parameters.ConfigureAsUint( "MinimumSize" );
-
- this->m_Parameters.SetUint( "InsideValue", 1 );
- this->m_Parameters.SetUint( "OutsideValue", 0 );
- this->m_Parameters.SetUint( "MinimumSize", 100 );
-}
-
-// -------------------------------------------------------------------------
-cpPluginsImageMeshFilters::TriangleMeshToBinaryImageFilter::
-~TriangleMeshToBinaryImageFilter( )
-{
-}
-
-// -------------------------------------------------------------------------
-void cpPluginsImageMeshFilters::TriangleMeshToBinaryImageFilter::
-_GenerateData( )
-{
- typedef itk::Mesh< float, 3 > _3F;
- typedef itk::Mesh< double, 3 > _3D;
-
- auto _3f = this->GetInputData< _3F >( "Input" );
- auto _3d = this->GetInputData< _3D >( "Input" );
- if ( _3f != NULL ) this->_GD0( _3f );
- else if( _3d != NULL ) this->_GD0( _3d );
- else this->_Error( "No valid input mesh." );
-}
-
-// -------------------------------------------------------------------------
-template< class _TMesh >
-void cpPluginsImageMeshFilters::TriangleMeshToBinaryImageFilter::
-_GD0( _TMesh* mesh )
-{
- this->_GD1< _TMesh, unsigned char >( mesh );
-}
-
-// -------------------------------------------------------------------------
-template< class _TMesh, class _TPixel >
-void cpPluginsImageMeshFilters::TriangleMeshToBinaryImageFilter::
-_GD1( _TMesh* mesh )
-{
- typedef cpPlugins::DataObjects::BoundingBox _TBB;
- typedef itk::Image< _TPixel, _TMesh::PointDimension > _TImage;
- typedef itk::TriangleMeshToBinaryImageFilter< _TMesh, _TImage > _TFilter;
- typedef typename _TImage::PointType _TPoint;
-
- static const unsigned int PAD = 10;
-
- _TFilter* filter = this->_CreateITK< _TFilter >( );
-
- auto in_bb = dynamic_cast< _TBB* >( this->GetInput( "BoundingBox" ) );
- _TPoint minBB, maxBB;
- if( in_bb == NULL )
- {
- auto bb = mesh->GetBoundingBox( );
- minBB = bb->GetMinimum( );
- maxBB = bb->GetMaximum( );
- }
- else
- {
- minBB = in_bb->GetMinimum< _TPoint >( );
- maxBB = in_bb->GetMaximum< _TPoint >( );
-
- } // fi
-
- double lx = double( maxBB[ 0 ] - minBB[ 0 ] );
- double ly = double( maxBB[ 1 ] - minBB[ 1 ] );
- double lz = double( maxBB[ 2 ] - minBB[ 2 ] );
- double lm = ( lx < ly )? lx: ly;
- lm = ( lm < lz )? lm: lz;
-
- // Compute spacing
- double mSpac = lm / double( this->m_Parameters.GetUint( "MinimumSize" ) );
- typename _TImage::SpacingType spac;
- spac.Fill( mSpac );
- filter->SetSpacing( spac );
-
- // Compute size
- typename _TImage::SizeType size;
- size[ 0 ] = ( unsigned long )( std::ceil( lx / mSpac ) );
- size[ 1 ] = ( unsigned long )( std::ceil( ly / mSpac ) );
- size[ 2 ] = ( unsigned long )( std::ceil( lz / mSpac ) );
-
- // ... add some padding pixels
- size[ 0 ] += PAD;
- size[ 1 ] += PAD;
- size[ 2 ] += PAD;
- filter->SetSize( size );
-
- // Set origin
- typename _TImage::PointType origin = minBB;
- origin[ 0 ] -= double( PAD >> 1 ) * spac[ 0 ];
- origin[ 1 ] -= double( PAD >> 1 ) * spac[ 1 ];
- origin[ 2 ] -= double( PAD >> 1 ) * spac[ 2 ];
- filter->SetOrigin( origin );
-
- // Remaining values
- typename _TImage::DirectionType direction;
- direction.SetIdentity( );
- filter->SetDirection( direction );
-
- typename _TImage::IndexType index;
- index.Fill( 0 );
- filter->SetIndex( index );
-
- // Execute
- filter->SetInput( mesh );
- filter->SetInsideValue( this->m_Parameters.GetUint( "InsideValue" ) );
- filter->SetOutsideValue( this->m_Parameters.GetUint( "OutsideValue" ) );
- filter->Update( );
-
- // Connect output
- this->GetOutput( "Output" )->SetITK( filter->GetOutput( ) );
-}
-
-// eof - $RCSfile$
+++ /dev/null
-#ifndef __CPPLUGINSIMAGEMESH__TRIANGLEMESHTOBINARYIMAGEFILTER__H__
-#define __CPPLUGINSIMAGEMESH__TRIANGLEMESHTOBINARYIMAGEFILTER__H__
-
-#include <plugins/cpPluginsImageMeshFilters_Export.h>
-#include <cpPlugins/BaseObjects/ProcessObject.h>
-
-namespace cpPluginsImageMeshFilters
-{
- /**
- */
- class cpPluginsImageMeshFilters_EXPORT TriangleMeshToBinaryImageFilter
- : public cpPlugins::BaseObjects::ProcessObject
- {
- cpPluginsObject(
- TriangleMeshToBinaryImageFilter,
- cpPlugins::BaseObjects::ProcessObject,
- MeshToImageFilters
- );
-
- protected:
- template< class _TMesh >
- inline void _GD0( _TMesh* mesh );
-
- template< class _TMesh, class _TPixel >
- inline void _GD1( _TMesh* mesh );
- };
-
-} // ecapseman
-
-#endif // __CPPLUGINSIMAGEMESH__TRIANGLEMESHTOBINARYIMAGEFILTER__H__
-
-// eof - $RCSfile$
#include <vtkCommand.h>
#include <vtkImageActor.h>
+#include <vtkImageData.h>
#include <vtkProperty.h>
#include <vtkRenderer.h>
#include <vtkRenderWindowInteractor.h>
#include <cpPlugins/DataObjects/Mesh.h>
#include <cpExtensions/Visualization/WindowLevelImageActor.h>
+#include <vtkImageData.h>
#include <vtkRenderer.h>
#include <vtkSplineWidget.h>