1 #include "MeshReader.h"
2 #include <cpPlugins/Interface/Mesh.h>
4 #include <vtkPolyData.h>
5 #include <vtkPolyDataReader.h>
7 #ifdef cpPlugins_Interface_QT4
9 #endif // cpPlugins_Interface_QT4
11 // -------------------------------------------------------------------------
12 bool cpPlugins::IO::MeshReader::
13 ExecConfigurationDialog( QWidget* parent )
17 #ifdef cpPlugins_Interface_QT4
19 // Show dialog and check if it was accepted
20 QFileDialog dialog( parent );
21 dialog.setFileMode( QFileDialog::ExistingFile );
22 dialog.setDirectory( QFileDialog::tr( "." ) );
23 dialog.setNameFilter( QFileDialog::tr( "All files (*)" ) );
26 this->m_Parameters = this->m_DefaultParameters;
27 QStringList names = dialog.selectedFiles( );
28 this->m_Parameters.AddValueToStringList(
29 "FileNames", names[ 0 ].toStdString( )
33 this->m_Parameters.SetValueAsString( "PixelType", "float" );
34 this->m_Parameters.SetValueAsUint( "Dimension", 3 );
41 #endif // cpPlugins_Interface_QT4
46 // -------------------------------------------------------------------------
47 cpPlugins::IO::MeshReader::
51 this->m_ClassName = "cpPlugins::IO::MeshReader";
52 this->m_ClassCategory = "MeshReader";
54 this->SetNumberOfOutputs( 1 );
55 this->_MakeOutput< cpPlugins::Interface::Mesh >( 0 );
57 using namespace cpPlugins::Interface;
58 this->m_DefaultParameters.Configure( Parameters::String, "FileName" );
59 this->m_DefaultParameters.Configure( Parameters::String, "PixelType" );
60 this->m_DefaultParameters.Configure( Parameters::Uint, "Dimension" );
61 this->m_DefaultParameters.SetValueAsString( "PixelType", "float" );
62 this->m_DefaultParameters.SetValueAsUint( "Dimension", 3 );
63 this->m_Parameters = this->m_DefaultParameters;
66 // -------------------------------------------------------------------------
67 cpPlugins::IO::MeshReader::
72 // -------------------------------------------------------------------------
73 std::string cpPlugins::IO::MeshReader::
76 using namespace cpPlugins::Interface;
77 Parameters::TUint dim = this->m_Parameters.GetValueAsUint( "Dimension" );
78 std::string r = "MeshReader: Mesh dimension not supported.";
80 r = this->_GD0< 2 >( );
82 r = this->_GD0< 3 >( );
86 // -------------------------------------------------------------------------
87 template< unsigned int D >
88 std::string cpPlugins::IO::MeshReader::
91 using namespace cpPlugins::Interface;
92 Parameters::TString pt = this->m_Parameters.GetValueAsString( "PixelType" );
93 std::string r = "MeshReader: Mesh pixel type not supported";
94 if( pt == "float" ) r = this->_GD1< float, D >( );
95 else if( pt == "double" ) r = this->_GD1< double, D >( );
99 // -------------------------------------------------------------------------
100 template< class P, unsigned int D >
101 std::string cpPlugins::IO::MeshReader::
105 using namespace cpPlugins::Interface;
106 Parameters::TString fname =
107 this->m_Parameters.GetValueAsString( "FileName" );
109 vtkPolyDataReader* pdr = this->_CreateVTK< vtkPolyDataReader >( );
110 pdr->SetFileName( fname.c_str( ) );
113 cpPlugins::Interface::Mesh* out =
114 this->GetOutput< cpPlugins::Interface::Mesh >( 0 );
116 out->SetVTK( pdr->GetOutput( ) );
118 return( "MeshReader: output not correctly created." );