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", true );
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" );
33 return( "MeshWriter: No input mesh." );
34 vtkPolyData* i = mesh->GetVTK< vtkPolyData >( );
36 return( "MeshWriter: No suitable input." );
37 std::string fname = this->m_Parameters->GetSaveFileName( "FileName" );
39 vtkPolyDataWriter* pdw = this->_CreateVTK< vtkPolyDataWriter >( );
40 pdw->SetInputData( i );
41 pdw->SetFileName( fname.c_str( ) );
42 pdw->SetFileTypeToBinary( );
44 if( pdw->GetErrorCode( ) != 0 )
45 return( "MeshWriter: someting wrong happened." );