#include #include #include #include // ------------------------------------------------------------------------- std::string cpPlugins::Plugins::MeshReader:: GetClassName( ) const { return( "cpPlugins::Plugins::MeshReader" ); } // ------------------------------------------------------------------------- cpPlugins::Plugins::MeshReader:: MeshReader( ) : Superclass( ) { this->SetNumberOfOutputs( 1 ); this->_MakeOutput< cpPlugins::Interface::Mesh >( 0 ); using namespace cpPlugins::Interface; this->m_DefaultParameters.Configure( Parameters::String, "FileName" ); this->m_DefaultParameters.Configure( Parameters::String, "PixelType" ); this->m_DefaultParameters.Configure( Parameters::Uint, "Dimension" ); this->m_DefaultParameters.SetValueAsString( "PixelType", "float" ); this->m_DefaultParameters.SetValueAsUint( "Dimension", 3 ); this->m_Parameters = this->m_DefaultParameters; } // ------------------------------------------------------------------------- cpPlugins::Plugins::MeshReader:: ~MeshReader( ) { } // ------------------------------------------------------------------------- std::string cpPlugins::Plugins::MeshReader:: _GenerateData( ) { using namespace cpPlugins::Interface; Parameters::TUint dim = this->m_Parameters.GetValueAsUint( "Dimension" ); std::string r = "cpPlugins::Plugins::MeshReader: itk::Mesh dimension not supported."; if( dim == 3 ) r = this->_GD0< 3 >( ); return( r ); } // ------------------------------------------------------------------------- template< unsigned int D > std::string cpPlugins::Plugins::MeshReader:: _GD0( ) { using namespace cpPlugins::Interface; Parameters::TString pt = this->m_Parameters.GetValueAsString( "PixelType" ); std::string r = "cpPlugins::Plugins::MeshReader: itk::Mesh pixel type not supported"; if( pt == "float" ) r = this->_GD1< float, D >( ); else if( pt == "double" ) r = this->_GD1< double, D >( ); return( r ); } // ------------------------------------------------------------------------- template< class P, unsigned int D > std::string cpPlugins::Plugins::MeshReader:: _GD1( ) { // Get filename using namespace cpPlugins::Interface; Parameters::TString fname = this->m_Parameters.GetValueAsString( "FileName" ); using namespace cpPlugins::Extensions; typedef DataStructures::QuadEdgeMesh< P, D > _TMesh; typedef IO::MeshReader< _TMesh > _TReader; _TReader* reader = dynamic_cast< _TReader* >( this->m_RealProcessObject.GetPointer( ) ); if( reader == NULL ) { this->m_RealProcessObject = _TReader::New( ); reader = dynamic_cast< _TReader* >( this->m_RealProcessObject.GetPointer( ) ); } // fi reader->SetFileName( fname ); try { reader->Update( ); } catch( itk::ExceptionObject& err ) { return( err.GetDescription( ) ); } // yrt this->_SetOutput( 0, reader->GetOutput( ) ); return( "" ); } // eof - $RCSfile$