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 QStringList names = dialog.selectedFiles( );
27 this->m_Parameters->SetString( "FileName", names[ 0 ].toStdString( ) );
28 this->m_Parameters->SetSelectedChoice( "PixelType", "float" );
29 this->m_Parameters->SetUint( "Dimension", 3 );
35 #endif // cpPlugins_Interface_QT4
40 // -------------------------------------------------------------------------
41 cpPlugins::IO::MeshReader::
45 this->_MakeOutput< cpPlugins::Interface::Mesh >( "Output" );
47 std::vector< TParameters::TString > valid_types;
48 valid_types.push_back( "float" );
49 valid_types.push_back( "double" );
50 this->m_Parameters->ConfigureAsString( "FileName", "" );
51 this->m_Parameters->ConfigureAsChoices( "PixelType", valid_types );
52 this->m_Parameters->ConfigureAsUint( "Dimension", 3 );
55 // -------------------------------------------------------------------------
56 cpPlugins::IO::MeshReader::
61 // -------------------------------------------------------------------------
62 std::string cpPlugins::IO::MeshReader::
65 using namespace cpPlugins::Interface;
66 Parameters::TUint dim = this->m_Parameters->GetUint( "Dimension" );
67 std::string r = "MeshReader: Mesh dimension not supported.";
69 r = this->_GD0< 2 >( );
71 r = this->_GD0< 3 >( );
75 // -------------------------------------------------------------------------
76 template< unsigned int D >
77 std::string cpPlugins::IO::MeshReader::
80 using namespace cpPlugins::Interface;
81 Parameters::TString pt =
82 this->m_Parameters->GetSelectedChoice( "PixelType" );
83 std::string r = "MeshReader: Mesh pixel type not supported";
84 if( pt == "float" ) r = this->_GD1< float, D >( );
85 else if( pt == "double" ) r = this->_GD1< double, D >( );
89 // -------------------------------------------------------------------------
90 template< class P, unsigned int D >
91 std::string cpPlugins::IO::MeshReader::
95 std::string fname = this->m_Parameters->GetString( "FileName" );
97 vtkPolyDataReader* pdr = this->_CreateVTK< vtkPolyDataReader >( );
98 pdr->SetFileName( fname.c_str( ) );
101 cpPlugins::Interface::Mesh* out =
102 this->GetOutput< cpPlugins::Interface::Mesh >( "Output" );
104 out->SetVTK( pdr->GetOutput( ) );
106 return( "MeshReader: output not correctly created." );