1 #include "MeshWriter.h"
2 #include <cpPlugins/Interface/Mesh.h>
4 #include <vtkSmartPointer.h>
5 #include <vtkPolyData.h>
6 #include <vtkPolyDataWriter.h>
9 #ifdef cpPlugins_Interface_QT4
10 #include <QFileDialog>
11 #endif // cpPlugins_Interface_QT4
13 // -------------------------------------------------------------------------
14 cpPlugins::IO::MeshWriter::
15 DialogResult cpPlugins::IO::MeshWriter::
16 ExecConfigurationDialog( QWidget* parent )
18 DialogResult r = Self::DialogResult_Cancel;
20 #ifdef cpPlugins_Interface_QT4
22 std::string name = this->m_Parameters->GetString( "FileName" );
26 // Show dialog and check if it was accepted
28 QFileDialog::getSaveFileName(
30 QFileDialog::tr( "Save File" ),
31 QFileDialog::tr( name.c_str( ) ),
32 QFileDialog::tr( "Mesh files (*.vtk *.stl *.obj);;Any file (*)")
34 name = qname.toStdString( );
37 this->m_Parameters->SetString( "FileName", name );
38 r = Self::DialogResult_NoModal;
42 #endif // cpPlugins_Interface_QT4
48 // -------------------------------------------------------------------------
49 cpPlugins::IO::MeshWriter::
53 this->_AddInput( "Input" );
54 this->m_Parameters->ConfigureAsSaveFileName( "FileName" );
57 // -------------------------------------------------------------------------
58 cpPlugins::IO::MeshWriter::
63 // -------------------------------------------------------------------------
64 std::string cpPlugins::IO::MeshWriter::
67 auto mesh = this->GetInputData< cpPlugins::Interface::Mesh >( "Input" );
69 return( "MeshWriter: No input mesh." );
70 vtkPolyData* i = mesh->GetVTK< vtkPolyData >( );
72 return( "MeshWriter: No suitable input." );
73 std::string fname = this->m_Parameters->GetSaveFileName( "FileName" );
75 vtkPolyDataWriter* pdw = this->_CreateVTK< vtkPolyDataWriter >( );
76 pdw->SetInputData( i );
77 pdw->SetFileName( fname.c_str( ) );
79 if( pdw->GetErrorCode( ) != 0 )
80 return( "MeshWriter: someting wrong happened." );