1 #include "MeshWriter.h"
2 #include <cpPlugins/Interface/Mesh.h>
4 #include <vtkSmartPointer.h>
5 #include <vtkPolyData.h>
6 #include <vtkPolyDataWriter.h>
8 // -------------------------------------------------------------------------
9 cpPlugins::IO::MeshWriter::
14 this->m_ClassName = "cpPlugins::IO::MeshWriter";
15 this->m_ClassCategory = "MeshWriter";
16 this->SetNumberOfInputs( 1 );
18 using namespace cpPlugins::Interface;
19 this->m_DefaultParameters.Configure( Parameters::String, "FileName" );
20 this->m_Parameters = this->m_DefaultParameters;
23 // -------------------------------------------------------------------------
24 cpPlugins::IO::MeshWriter::
27 if( this->m_Writer != NULL )
28 this->m_Writer->Delete( );
31 // -------------------------------------------------------------------------
32 std::string cpPlugins::IO::MeshWriter::
35 cpPlugins::Interface::Mesh* mesh =
36 this->GetInput< cpPlugins::Interface::Mesh >( 0 );
38 return( "MeshWriter: No input mesh." );
39 vtkPolyData* i = mesh->GetVTKMesh( );
41 return( "MeshWriter: No suitable input." );
42 std::string fname = this->m_Parameters.GetValueAsString( "FileName" );
44 if( this->m_Writer != NULL )
45 this->m_Writer->Delete( );
47 vtkPolyDataWriter* pdw = vtkPolyDataWriter::New( );
49 pdw->SetInputData( i );
50 pdw->SetFileName( fname.c_str( ) );
52 if( pdw->GetErrorCode( ) != 0 )
53 return( "MeshWriter: someting wrong happened." );