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 cpPlugins::Plugins::MeshReader::
12 this->SetNumberOfOutputs( 1 );
13 this->_MakeOutput< cpPlugins::Interface::Mesh >( 0 );
15 this->m_DefaultParameters[ "FileName" ] =
16 TParameter( "string", "no_file_name" );
17 this->m_DefaultParameters[ "PixelType" ] = TParameter( "type", "float" );
18 this->m_DefaultParameters[ "MeshDimension" ] = TParameter( "int", "3" );
21 // -------------------------------------------------------------------------
22 cpPlugins::Plugins::MeshReader::
27 // -------------------------------------------------------------------------
28 std::string cpPlugins::Plugins::MeshReader::
31 return( "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_Reader.GetPointer( ) );
91 this->m_Reader = _TReader::New( );
92 reader = dynamic_cast< _TReader* >( this->m_Reader.GetPointer( ) );
95 reader->SetFileName( fIt->second.second );
100 catch( itk::ExceptionObject& err )
102 return( err.GetDescription( ) );
105 this->_SetOutput( 0, reader->GetOutput( ) );