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 this->m_DefaultParameters[ "FileName" ] =
23 TParameter( "string", "no_file_name" );
24 this->m_DefaultParameters[ "PixelType" ] = TParameter( "type", "float" );
25 this->m_DefaultParameters[ "MeshDimension" ] = TParameter( "int", "3" );
28 // -------------------------------------------------------------------------
29 cpPlugins::Plugins::MeshReader::
34 // -------------------------------------------------------------------------
35 std::string cpPlugins::Plugins::MeshReader::
38 TParameters::const_iterator dIt;
40 // Get image dimension
41 dIt = this->m_Parameters.find( "MeshDimension" );
42 if( dIt == this->m_Parameters.end( ) )
43 dIt = this->m_DefaultParameters.find( "MeshDimension" );
45 std::string r = "cpPlugins::Plugins::MeshReader: itk::Mesh dimension not supported.";
46 if( dIt->second.second == "3" ) r = this->_GD0< 3 >( );
51 // -------------------------------------------------------------------------
52 template< unsigned int D >
53 std::string cpPlugins::Plugins::MeshReader::
56 TParameters::const_iterator tIt, cIt;
58 // Get image pixel type
59 tIt = this->m_Parameters.find( "PixelType" );
60 if( tIt == this->m_Parameters.end( ) )
61 tIt = this->m_DefaultParameters.find( "PixelType" );
63 std::string r = "cpPlugins::Plugins::MeshReader: itk::Mesh pixel type not supported";
64 if( tIt->second.second == "float" )
65 r = this->_GD1< float, D >( );
66 else if( tIt->second.second == "double" )
67 r = this->_GD1< double, D >( );
71 // -------------------------------------------------------------------------
72 template< class P, unsigned int D >
73 std::string cpPlugins::Plugins::MeshReader::
76 TParameters::const_iterator fIt;
79 fIt = this->m_Parameters.find( "FileName" );
80 if( fIt == this->m_Parameters.end( ) )
81 fIt = this->m_DefaultParameters.find( "FileName" );
83 using namespace cpPlugins::Extensions;
84 typedef DataStructures::QuadEdgeMesh< P, D > _TMesh;
85 typedef IO::MeshReader< _TMesh > _TReader;
88 dynamic_cast< _TReader* >( this->m_RealProcessObject.GetPointer( ) );
91 this->m_RealProcessObject = _TReader::New( );
93 dynamic_cast< _TReader* >( this->m_RealProcessObject.GetPointer( ) );
96 reader->SetFileName( fIt->second.second );
101 catch( itk::ExceptionObject& err )
103 return( err.GetDescription( ) );
106 this->_SetOutput( 0, reader->GetOutput( ) );