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::
13 this->m_ClassName = "cpPlugins::IO::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::IO::MeshWriter::
28 // -------------------------------------------------------------------------
29 std::string cpPlugins::IO::MeshWriter::
32 cpPlugins::Interface::Mesh* mesh =
33 this->GetInput< cpPlugins::Interface::Mesh >( 0 );
35 return( "MeshWriter: No input mesh." );
36 vtkPolyData* i = mesh->GetVTK< vtkPolyData >( );
38 return( "MeshWriter: No suitable input." );
39 std::string fname = this->m_Parameters.GetValueAsString( "FileName" );
41 vtkPolyDataWriter* pdw = this->_CreateVTK< vtkPolyDataWriter >( );
42 pdw->SetInputData( i );
43 pdw->SetFileName( fname.c_str( ) );
45 if( pdw->GetErrorCode( ) != 0 )
46 return( "MeshWriter: someting wrong happened." );