]> Creatis software - cpPlugins.git/blob - plugins/VTKIO/MeshReader.cxx
...
[cpPlugins.git] / plugins / VTKIO / MeshReader.cxx
1 #include <VTKIO/MeshReader.h>
2 #include <cpInstances/DataObjects/Mesh.h>
3 #include <cpPlugins/QT/OpenFileDialog.h>
4
5 #include <vtkPolyData.h>
6 #include <vtkPolyDataReader.h>
7
8 #ifdef cpPlugins_QT4
9 #  include <QApplication>
10 #endif // cpPlugins_QT4
11
12 // -------------------------------------------------------------------------
13 QDialog* cpPluginsVTKIO::MeshReader::
14 CreateQDialog( )
15 {
16 #ifdef cpPlugins_QT4
17   cpPlugins::QT::OpenFileDialog* dlg = NULL;
18   if( QApplication::instance( ) != NULL )
19   {
20     dlg = new cpPlugins::QT::OpenFileDialog( );
21     dlg->SetParameters( &( this->m_Parameters ), "FileName" );
22
23   } // fi
24   return( dlg );
25 #else // cpPlugins_QT4
26   return( NULL );
27 #endif // cpPlugins_QT4
28 }
29
30 // -------------------------------------------------------------------------
31 cpPluginsVTKIO::MeshReader::
32 MeshReader( )
33   : Superclass( )
34 {
35   this->_ConfigureOutput< cpInstances::DataObjects::Mesh >( "Output" );
36   this->m_Parameters.Clear( );
37   this->m_Parameters.ConfigureAsOpenFileName( "FileName", "" );
38   this->m_Parameters.SetAcceptedFileExtensions(
39     "FileName",
40     "Mesh files (*.vtk)"
41     );
42 }
43
44 // -------------------------------------------------------------------------
45 cpPluginsVTKIO::MeshReader::
46 ~MeshReader( )
47 {
48 }
49
50 // -------------------------------------------------------------------------
51 void cpPluginsVTKIO::MeshReader::
52 _GenerateData( )
53 {
54   auto f = this->_CreateVTK< vtkPolyDataReader >( );
55   f->SetFileName( this->m_Parameters.GetOpenFileName( "FileName" ).c_str( ) );
56   f->Update( );
57   this->GetOutput( "Output" )->SetVTK( f->GetOutput( ) );
58 }
59
60 // eof - $RCSfile$