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" );
53 this->m_Parameters->ConfigureAsString( "FileName", "" );
56 // -------------------------------------------------------------------------
57 cpPlugins::IO::MeshWriter::
62 // -------------------------------------------------------------------------
63 std::string cpPlugins::IO::MeshWriter::
66 cpPlugins::Interface::Mesh* mesh =
67 this->GetInput< 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->GetString( "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." );