1 #include <cpPlugins/Plugins/MeshReader.h>
2 #include <cpPlugins/Interface/Mesh.h>
4 #include <cpPlugins/Extensions/DataStructures/QuadEdgeMesh.h>
5 #include <cpPlugins/Extensions/IO/MeshReader.h>
7 // -------------------------------------------------------------------------
8 std::string cpPlugins::Plugins::MeshReader::
11 return( "cpPlugins::Plugins::MeshReader" );
14 // -------------------------------------------------------------------------
15 cpPlugins::Plugins::MeshReader::
19 this->SetNumberOfOutputs( 1 );
20 this->_MakeOutput< cpPlugins::Interface::Mesh >( 0 );
22 using namespace cpPlugins::Interface;
23 this->m_DefaultParameters.Configure( Parameters::String, "FileName" );
24 this->m_DefaultParameters.Configure( Parameters::String, "PixelType" );
25 this->m_DefaultParameters.Configure( Parameters::Uint, "Dimension" );
26 this->m_DefaultParameters.SetValueAsString( "PixelType", "float" );
27 this->m_DefaultParameters.SetValueAsUint( "Dimension", 3 );
28 this->m_Parameters = this->m_DefaultParameters;
31 // -------------------------------------------------------------------------
32 cpPlugins::Plugins::MeshReader::
37 // -------------------------------------------------------------------------
38 std::string cpPlugins::Plugins::MeshReader::
41 using namespace cpPlugins::Interface;
42 Parameters::TUint dim = this->m_Parameters.GetValueAsUint( "Dimension" );
43 std::string r = "cpPlugins::Plugins::MeshReader: itk::Mesh dimension not supported.";
45 r = this->_GD0< 3 >( );
49 // -------------------------------------------------------------------------
50 template< unsigned int D >
51 std::string cpPlugins::Plugins::MeshReader::
54 using namespace cpPlugins::Interface;
55 Parameters::TString pt = this->m_Parameters.GetValueAsString( "PixelType" );
56 std::string r = "cpPlugins::Plugins::MeshReader: itk::Mesh pixel type not supported";
57 if( pt == "float" ) r = this->_GD1< float, D >( );
58 else if( pt == "double" ) r = this->_GD1< double, D >( );
62 // -------------------------------------------------------------------------
63 template< class P, unsigned int D >
64 std::string cpPlugins::Plugins::MeshReader::
68 using namespace cpPlugins::Interface;
69 Parameters::TString fname =
70 this->m_Parameters.GetValueAsString( "FileName" );
72 using namespace cpPlugins::Extensions;
73 typedef DataStructures::QuadEdgeMesh< P, D > _TMesh;
74 typedef IO::MeshReader< _TMesh > _TReader;
77 dynamic_cast< _TReader* >( this->m_RealProcessObject.GetPointer( ) );
80 this->m_RealProcessObject = _TReader::New( );
82 dynamic_cast< _TReader* >( this->m_RealProcessObject.GetPointer( ) );
85 reader->SetFileName( fname );
90 catch( itk::ExceptionObject& err )
92 return( err.GetDescription( ) );
95 this->_SetOutput( 0, reader->GetOutput( ) );