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 bool cpPlugins::IO::MeshWriter::
14 ExecConfigurationDialog( QWidget* parent )
18 #ifdef cpPlugins_Interface_QT4
20 std::string name = this->m_Parameters->GetString( "FileName" );
24 // Show dialog and check if it was accepted
26 QFileDialog::getSaveFileName(
28 QFileDialog::tr( "Save File" ),
29 QFileDialog::tr( name.c_str( ) ),
30 QFileDialog::tr( "Mesh files (*.vtk *.stl *.obj);;Any file (*)")
32 name = qname.toStdString( );
35 this->m_Parameters->SetString( "FileName", name );
40 #endif // cpPlugins_Interface_QT4
45 // -------------------------------------------------------------------------
46 cpPlugins::IO::MeshWriter::
50 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." );