]> Creatis software - cpPlugins.git/blob - lib/cpPlugins/Plugins/IO/MeshWriter.cxx
Intermediary commit
[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->SetNumberOfInputs( 1 );
14
15   using namespace cpPlugins::Interface;
16   this->m_DefaultParameters.Configure( Parameters::String, "FileName" );
17   this->m_Parameters = this->m_DefaultParameters;
18 }
19
20 // -------------------------------------------------------------------------
21 cpPlugins::IO::MeshWriter::
22 ~MeshWriter( )
23 {
24 }
25
26 // -------------------------------------------------------------------------
27 std::string cpPlugins::IO::MeshWriter::
28 _GenerateData( )
29 {
30   cpPlugins::Interface::Mesh* mesh =
31     this->GetInput< cpPlugins::Interface::Mesh >( 0 );
32   if( mesh == NULL )
33     return( "MeshWriter: No input mesh." );
34   vtkPolyData* i = mesh->GetVTK< vtkPolyData >( );
35   if( i == NULL )
36     return( "MeshWriter: No suitable input." );
37   std::string fname = this->m_Parameters.GetValueAsString( "FileName" );
38
39   vtkPolyDataWriter* pdw = this->_CreateVTK< vtkPolyDataWriter >( );
40   pdw->SetInputData( i );
41   pdw->SetFileName( fname.c_str( ) );
42   pdw->Update( );
43   if( pdw->GetErrorCode( ) != 0 )
44     return( "MeshWriter: someting wrong happened." );
45   return( "" );
46 }
47
48 // eof - $RCSfile$