]> Creatis software - cpPlugins.git/blobdiff - lib/cpPlugins/Plugins/MarchingCubes.cxx
...
[cpPlugins.git] / lib / cpPlugins / Plugins / MarchingCubes.cxx
index bc56f9cb4f9fd38e7df6d7d16a0e4a29225e200e..8187b42d0cdb51d743523ae28f9c7452a254f5b9 100644 (file)
@@ -36,34 +36,31 @@ std::string cpPlugins::Plugins::MarchingCubes::
 _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;
@@ -73,7 +70,9 @@ _GenerateData( )
 
   // 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( "" );
 }