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->_AddInput( "Input" );
14 this->m_Parameters->ConfigureAsSaveFileName( "FileName" );
15 this->m_Parameters->SetAcceptedFileExtensions(
17 "Mesh files (*.vtk *.stl *.obj)"
21 // -------------------------------------------------------------------------
22 cpPlugins::IO::MeshWriter::
27 // -------------------------------------------------------------------------
28 std::string cpPlugins::IO::MeshWriter::
31 auto mesh = this->GetInputData< cpPlugins::Interface::Mesh >( "Input" );
32 vtkPolyData* i = mesh->GetVTK< vtkPolyData >( );
34 return( "MeshWriter: No suitable input." );
35 std::string fname = this->m_Parameters->GetSaveFileName( "FileName" );
37 vtkPolyDataWriter* pdw = this->_CreateVTK< vtkPolyDataWriter >( );
38 pdw->SetInputData( i );
39 pdw->SetFileName( fname.c_str( ) );
40 pdw->SetFileTypeToBinary( );
42 if( pdw->GetErrorCode( ) != 0 )
43 return( "MeshWriter: someting wrong happened." );