m_Algorithm( NULL )
{
this->m_ClassName = "cpPlugins::MarchingCubes";
+ this->m_ClassCategory = "ImageToMeshFilter";
this->SetNumberOfInputs( 1 );
this->SetNumberOfOutputs( 1 );
_GenerateData( )
{
// Get input
- cpPlugins::Interface::Image* input =
- dynamic_cast< cpPlugins::Interface::Image* >(
- this->m_Inputs[ 0 ].GetPointer( )
- );
- if( input == NULL )
+ cpPlugins::Interface::Image* image =
+ this->_Input< cpPlugins::Interface::Image >( 0 );
+ if( image == NULL )
return( "MarchingCubes: Input data is not a valid image." );
- vtkImageData* vtk_input =
- dynamic_cast< vtkImageData* >( input->GetVTKDataObject( ) );
- if( vtk_input == NULL )
- return( "MarchingCubes: Input does not have a valid conversion to VTK." );
+ vtkImageData* vtk_image = image->GetVTKImageData( );
+ if( vtk_image == NULL )
+ return( "MarchingCubes: Input does not have a valid VTK conversion." );
if( this->m_Algorithm != NULL )
this->m_Algorithm->Delete( );
std::vector< double > values;
this->m_Parameters.GetValueAsRealList( values, "Thresholds" );
- if( vtk_input->GetDataDimension( ) == 2 )
+ if( vtk_image->GetDataDimension( ) == 2 )
{
vtkMarchingSquares* ms = vtkMarchingSquares::New( );
- ms->SetInputData( vtk_input );
+ ms->SetInputData( vtk_image );
for( unsigned int i = 0; i < values.size( ); ++i )
ms->SetValue( i, values[ i ] );
this->m_Algorithm = ms;
}
- else if( vtk_input->GetDataDimension( ) == 3 )
+ else if( vtk_image->GetDataDimension( ) == 3 )
{
vtkMarchingCubes* mc = vtkMarchingCubes::New( );
- mc->SetInputData( vtk_input );
+ mc->SetInputData( vtk_image );
for( unsigned int i = 0; i < values.size( ); ++i )
mc->SetValue( i, values[ i ] );
this->m_Algorithm = mc;
// Execute filter
this->m_Algorithm->Update( );
- this->m_Outputs[ 0 ]->SetVTKDataObject( this->m_Algorithm->GetOutput( ) );
+ cpPlugins::Interface::Mesh* out =
+ this->_Output< cpPlugins::Interface::Mesh >( 0 );
+ out->SetVTKMesh( this->m_Algorithm->GetOutput( ) );
return( "" );
}