]> Creatis software - cpPlugins.git/blob - lib/cpPlugins/Plugins/IO/MeshWriter.cxx
Widget integration (step 6/6): Interactive architecture finished. Needs to be tested...
[cpPlugins.git] / lib / cpPlugins / Plugins / IO / MeshWriter.cxx
1 #include "MeshWriter.h"
2 #include <cpPlugins/Interface/Mesh.h>
3
4 #include <vtkSmartPointer.h>
5 #include <vtkPolyData.h>
6 #include <vtkPolyDataWriter.h>
7
8 // -------------------------------------------------------------------------
9 cpPlugins::IO::MeshWriter::
10 MeshWriter( )
11   : Superclass( )
12 {
13   this->_AddInput( "Input" );
14
15   this->m_Parameters->ConfigureAsString( "FileName", "" );
16 }
17
18 // -------------------------------------------------------------------------
19 cpPlugins::IO::MeshWriter::
20 ~MeshWriter( )
21 {
22 }
23
24 // -------------------------------------------------------------------------
25 std::string cpPlugins::IO::MeshWriter::
26 _GenerateData( )
27 {
28   cpPlugins::Interface::Mesh* mesh =
29     this->GetInput< cpPlugins::Interface::Mesh >( "Input" );
30   if( mesh == NULL )
31     return( "MeshWriter: No input mesh." );
32   vtkPolyData* i = mesh->GetVTK< vtkPolyData >( );
33   if( i == NULL )
34     return( "MeshWriter: No suitable input." );
35   std::string fname = this->m_Parameters->GetString( "FileName" );
36
37   vtkPolyDataWriter* pdw = this->_CreateVTK< vtkPolyDataWriter >( );
38   pdw->SetInputData( i );
39   pdw->SetFileName( fname.c_str( ) );
40   pdw->Update( );
41   if( pdw->GetErrorCode( ) != 0 )
42     return( "MeshWriter: someting wrong happened." );
43   return( "" );
44 }
45
46 // eof - $RCSfile$