1 #include <cpPlugins/Plugins/MeshWriter.h>
3 #include <vtkSmartPointer.h>
4 #include <vtkPolyData.h>
5 #include <vtkPolyDataWriter.h>
7 // -------------------------------------------------------------------------
8 cpPlugins::Plugins::MeshWriter::
13 this->m_ClassName = "cpPlugins::MeshWriter";
14 this->m_ClassCategory = "MeshWriter";
15 this->SetNumberOfInputs( 1 );
17 using namespace cpPlugins::Interface;
18 this->m_DefaultParameters.Configure( Parameters::String, "FileName" );
19 this->m_Parameters = this->m_DefaultParameters;
22 // -------------------------------------------------------------------------
23 cpPlugins::Plugins::MeshWriter::
26 if( this->m_Writer != NULL )
27 this->m_Writer->Delete( );
30 // -------------------------------------------------------------------------
31 std::string cpPlugins::Plugins::MeshWriter::
35 dynamic_cast< vtkPolyData* >(
36 this->m_Inputs[ 0 ]->GetVTKDataObject( )
39 return( "MeshWriter: No suitable input." );
40 std::string fname = this->m_Parameters.GetValueAsString( "FileName" );
42 if( this->m_Writer != NULL )
43 this->m_Writer->Delete( );
45 vtkPolyDataWriter* pdw = vtkPolyDataWriter::New( );
47 pdw->SetInputData( i );
48 pdw->SetFileName( fname.c_str( ) );
50 if( pdw->GetErrorCode( ) != 0 )
51 return( "MeshWriter: someting wrong happened." );