1 #include <cpPlugins/Plugins/MeshReader.h>
2 #include <cpPlugins/Interface/Mesh.h>
4 #include <vtkPolyData.h>
5 #include <vtkPolyDataReader.h>
7 // -------------------------------------------------------------------------
8 cpPlugins::Plugins::MeshReader::
12 this->m_ClassName = "cpPlugins::MeshReader";
13 this->m_ClassCategory = "MeshReader";
15 this->SetNumberOfOutputs( 1 );
16 this->_MakeOutput< cpPlugins::Interface::Mesh >( 0 );
18 using namespace cpPlugins::Interface;
19 this->m_DefaultParameters.Configure( Parameters::String, "FileName" );
20 this->m_DefaultParameters.Configure( Parameters::String, "PixelType" );
21 this->m_DefaultParameters.Configure( Parameters::Uint, "Dimension" );
22 this->m_DefaultParameters.SetValueAsString( "PixelType", "float" );
23 this->m_DefaultParameters.SetValueAsUint( "Dimension", 3 );
24 this->m_Parameters = this->m_DefaultParameters;
27 // -------------------------------------------------------------------------
28 cpPlugins::Plugins::MeshReader::
33 // -------------------------------------------------------------------------
34 std::string cpPlugins::Plugins::MeshReader::
37 using namespace cpPlugins::Interface;
38 Parameters::TUint dim = this->m_Parameters.GetValueAsUint( "Dimension" );
39 std::string r = "MeshReader: Mesh dimension not supported.";
41 r = this->_GD0< 3 >( );
45 // -------------------------------------------------------------------------
46 template< unsigned int D >
47 std::string cpPlugins::Plugins::MeshReader::
50 using namespace cpPlugins::Interface;
51 Parameters::TString pt = this->m_Parameters.GetValueAsString( "PixelType" );
52 std::string r = "MeshReader: Mesh pixel type not supported";
53 if( pt == "float" ) r = this->_GD1< float, D >( );
54 else if( pt == "double" ) r = this->_GD1< double, D >( );
58 // -------------------------------------------------------------------------
59 template< class P, unsigned int D >
60 std::string cpPlugins::Plugins::MeshReader::
64 using namespace cpPlugins::Interface;
65 Parameters::TString fname =
66 this->m_Parameters.GetValueAsString( "FileName" );
68 if( this->m_Reader != NULL )
69 this->m_Reader->Delete( );
71 vtkPolyDataReader* pdr = vtkPolyDataReader::New( );
73 pdr->SetFileName( fname.c_str( ) );
75 this->m_Outputs[ 0 ]->SetVTKDataObject( pdr->GetOutput( ) );