1 #include "MeshWriter.h"
2 #include <cpPlugins/Interface/Mesh.h>
4 #include <vtkSmartPointer.h>
5 #include <vtkPolyData.h>
6 #include <vtkPolyDataWriter.h>
8 #ifdef cpPlugins_Interface_QT4
10 #endif // cpPlugins_Interface_QT4
12 // -------------------------------------------------------------------------
13 cpPlugins::IO::MeshWriter::
14 DialogResult cpPlugins::IO::MeshWriter::
15 ExecConfigurationDialog( QWidget* parent )
17 DialogResult r = Self::DialogResult_Cancel;
19 #ifdef cpPlugins_Interface_QT4
21 std::string name = this->m_Parameters->GetString( "FileName" );
25 // Show dialog and check if it was accepted
27 QFileDialog::getSaveFileName(
29 QFileDialog::tr( "Save File" ),
30 QFileDialog::tr( name.c_str( ) ),
31 QFileDialog::tr( "Mesh files (*.vtk *.stl *.obj);;Any file (*)")
33 name = qname.toStdString( );
36 this->m_Parameters->SetString( "FileName", name );
37 r = Self::DialogResult_NoModal;
41 #endif // cpPlugins_Interface_QT4
46 // -------------------------------------------------------------------------
47 cpPlugins::IO::MeshWriter::
51 this->_AddInput( "Input" );
52 this->m_Parameters->ConfigureAsString( "FileName" );
55 // -------------------------------------------------------------------------
56 cpPlugins::IO::MeshWriter::
61 // -------------------------------------------------------------------------
62 std::string cpPlugins::IO::MeshWriter::
65 cpPlugins::Interface::Mesh* mesh =
66 this->GetInput< cpPlugins::Interface::Mesh >( "Input" );
68 return( "MeshWriter: No input mesh." );
69 vtkPolyData* i = mesh->GetVTK< vtkPolyData >( );
71 return( "MeshWriter: No suitable input." );
72 std::string fname = this->m_Parameters->GetString( "FileName" );
74 vtkPolyDataWriter* pdw = this->_CreateVTK< vtkPolyDataWriter >( );
75 pdw->SetInputData( i );
76 pdw->SetFileName( fname.c_str( ) );
78 if( pdw->GetErrorCode( ) != 0 )
79 return( "MeshWriter: someting wrong happened." );