]> Creatis software - cpPlugins.git/blob - plugins/IO/MeshWriter.cxx
986eebbfbc0c2c0a3335052682810b2fbe830755
[cpPlugins.git] / plugins / IO / MeshWriter.cxx
1 #include <IO/MeshWriter.h>
2 #include <cpPlugins/DataObjects/Mesh.h>
3
4 #include <vtkPolyData.h>
5 #include <vtkPolyDataWriter.h>
6
7 // -------------------------------------------------------------------------
8 cpPluginsIO::MeshWriter::
9 MeshWriter( )
10   : Superclass( )
11 {
12   typedef cpPlugins::DataObjects::Mesh _TMesh;
13
14   this->_ConfigureInput< _TMesh >( "Input", true, false );
15   this->m_Parameters.Clear( );
16   this->m_Parameters.ConfigureAsSaveFileName( "FileName" );
17   this->m_Parameters.SetAcceptedFileExtensions(
18     "FileName",
19     "Mesh files (*.vtk)"
20     );
21 }
22
23 // -------------------------------------------------------------------------
24 cpPluginsIO::MeshWriter::
25 ~MeshWriter( )
26 {
27 }
28
29 // -------------------------------------------------------------------------
30 void cpPluginsIO::MeshWriter::
31 _GenerateData( )
32 {
33   auto mesh = this->GetInputData< vtkPolyData >( "Input" );
34   if( mesh == NULL )
35     this->_Error( "Invalid input image." );
36
37   auto f = this->_CreateVTK< vtkPolyDataWriter >( );
38   f->SetFileName( this->m_Parameters.GetSaveFileName( "FileName" ).c_str( ) );
39   f->SetInputData( mesh );
40   f->SetFileTypeToBinary( );
41   f->Update( );
42 }
43
44 // eof - $RCSfile$