X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=lib%2FcpPlugins%2FPlugins%2FBasicFilters%2FMarchingCubes.cxx;h=625838c08f6d8d353e139069e713a9b230d98586;hb=3633aade338a13bc83642e99e6d61b6499e4b3af;hp=e061017b328f68fddf64bc8cbafefc8bdecf0b2a;hpb=4f6c47b5d9994cd1bbb601bfe8bc087a0a619e72;p=cpPlugins.git diff --git a/lib/cpPlugins/Plugins/BasicFilters/MarchingCubes.cxx b/lib/cpPlugins/Plugins/BasicFilters/MarchingCubes.cxx index e061017..625838c 100644 --- a/lib/cpPlugins/Plugins/BasicFilters/MarchingCubes.cxx +++ b/lib/cpPlugins/Plugins/BasicFilters/MarchingCubes.cxx @@ -9,27 +9,18 @@ // ------------------------------------------------------------------------- cpPlugins::BasicFilters::MarchingCubes:: MarchingCubes( ) - : Superclass( ), - m_Algorithm( NULL ) + : Superclass( ) { - this->m_ClassName = "cpPlugins::BasicFilters::MarchingCubes"; - this->m_ClassCategory = "ImageToMeshFilter"; + this->_AddInput( "Input" ); + this->_MakeOutput< cpPlugins::Interface::Mesh >( "Output" ); - this->SetNumberOfInputs( 1 ); - this->SetNumberOfOutputs( 1 ); - this->_MakeOutput< cpPlugins::Interface::Mesh >( 0 ); - - using namespace cpPlugins::Interface; - this->m_DefaultParameters.Configure( Parameters::RealList, "Thresholds" ); - this->m_Parameters = this->m_DefaultParameters; + this->m_Parameters->ConfigureAsRealList( "Thresholds" ); } // ------------------------------------------------------------------------- cpPlugins::BasicFilters::MarchingCubes:: ~MarchingCubes( ) { - if( this->m_Algorithm != NULL ) - this->m_Algorithm->Delete( ); } // ------------------------------------------------------------------------- @@ -38,43 +29,42 @@ _GenerateData( ) { // Get input cpPlugins::Interface::Image* image = - this->GetInput< cpPlugins::Interface::Image >( 0 ); + this->GetInput< cpPlugins::Interface::Image >( "Input" ); if( image == NULL ) return( "MarchingCubes: Input data is not a valid image." ); - vtkImageData* vtk_image = image->GetVTKImageData( ); + vtkImageData* vtk_image = image->GetVTK< vtkImageData >( ); 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" ); + this->m_Parameters->GetRealList( values, "Thresholds" ); + vtkPolyData* pd = NULL; if( vtk_image->GetDataDimension( ) == 2 ) { - vtkMarchingSquares* ms = vtkMarchingSquares::New( ); + vtkMarchingSquares* ms = this->_CreateVTK< vtkMarchingSquares >( ); ms->SetInputData( vtk_image ); for( unsigned int i = 0; i < values.size( ); ++i ) ms->SetValue( i, values[ i ] ); - this->m_Algorithm = ms; + ms->Update( ); + pd = ms->GetOutput( ); } else if( vtk_image->GetDataDimension( ) == 3 ) { - vtkMarchingCubes* mc = vtkMarchingCubes::New( ); + vtkMarchingCubes* mc = this->_CreateVTK< vtkMarchingCubes >( ); mc->ComputeNormalsOff( ); mc->SetInputData( vtk_image ); for( unsigned int i = 0; i < values.size( ); ++i ) mc->SetValue( i, values[ i ] ); - this->m_Algorithm = mc; + mc->Update( ); + pd = mc->GetOutput( ); } else return( "MarchingCubes: Input data does not have a valid dimension." ); // Execute filter - this->m_Algorithm->Update( ); cpPlugins::Interface::Mesh* out = - this->GetOutput< cpPlugins::Interface::Mesh >( 0 ); - out->SetVTKMesh( this->m_Algorithm->GetOutput( ) ); + this->GetOutput< cpPlugins::Interface::Mesh >( "Output" ); + out->SetVTK( pd ); return( "" ); }