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 cpPlugins::Interface::Mesh* mesh =
68 this->GetInput< cpPlugins::Interface::Mesh >( "Input" );
70 return( "MeshWriter: No input mesh." );
71 vtkPolyData* i = mesh->GetVTK< vtkPolyData >( );
73 return( "MeshWriter: No suitable input." );
74 std::string fname = this->m_Parameters->GetSaveFileName( "FileName" );
76 vtkPolyDataWriter* pdw = this->_CreateVTK< vtkPolyDataWriter >( );
77 pdw->SetInputData( i );
78 pdw->SetFileName( fname.c_str( ) );
80 if( pdw->GetErrorCode( ) != 0 )
81 return( "MeshWriter: someting wrong happened." );