X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=lib%2FcpPlugins%2FPlugins%2FMeshReader.cxx;h=199325954b24e817bc063e99784bbec405cb5b7c;hb=96914c02e23847c9d4ecdd085da689e61abb58f8;hp=b7ce4ba88e3d5667232cef35c237d82a95854295;hpb=e286ff49ea3582a5f4fad437dd133ec6c05c34dc;p=cpPlugins.git diff --git a/lib/cpPlugins/Plugins/MeshReader.cxx b/lib/cpPlugins/Plugins/MeshReader.cxx index b7ce4ba..1993259 100644 --- a/lib/cpPlugins/Plugins/MeshReader.cxx +++ b/lib/cpPlugins/Plugins/MeshReader.cxx @@ -1,21 +1,18 @@ #include #include -#include -#include - -// ------------------------------------------------------------------------- -std::string cpPlugins::Plugins::MeshReader:: -GetClassName( ) const -{ - return( "cpPlugins::Plugins::MeshReader" ); -} +#include +#include // ------------------------------------------------------------------------- cpPlugins::Plugins::MeshReader:: MeshReader( ) - : Superclass( ) + : Superclass( ), + m_Reader( NULL ) { + this->m_ClassName = "cpPlugins::MeshReader"; + this->m_ClassCategory = "MeshReader"; + this->SetNumberOfOutputs( 1 ); this->_MakeOutput< cpPlugins::Interface::Mesh >( 0 ); @@ -32,6 +29,8 @@ MeshReader( ) cpPlugins::Plugins::MeshReader:: ~MeshReader( ) { + if( this->m_Reader != NULL ) + this->m_Reader = NULL; } // ------------------------------------------------------------------------- @@ -40,8 +39,10 @@ _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 ) + std::string r = "MeshReader: Mesh dimension not supported."; + if( dim == 2 ) + r = this->_GD0< 2 >( ); + else if( dim == 3 ) r = this->_GD0< 3 >( ); return( r ); } @@ -53,7 +54,7 @@ _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"; + std::string r = "MeshReader: Mesh pixel type not supported"; if( pt == "float" ) r = this->_GD1< float, D >( ); else if( pt == "double" ) r = this->_GD1< double, D >( ); return( r ); @@ -69,31 +70,20 @@ _GD1( ) 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( ) ); + if( this->m_Reader != NULL ) + this->m_Reader->Delete( ); - } // yrt - this->_SetOutput( 0, reader->GetOutput( ) ); + vtkPolyDataReader* pdr = vtkPolyDataReader::New( ); + this->m_Reader = pdr; + pdr->SetFileName( fname.c_str( ) ); + pdr->Update( ); + cpPlugins::Interface::Mesh* out = + this->GetOutput< cpPlugins::Interface::Mesh >( 0 ); + if( out != NULL ) + out->SetVTKMesh( pdr->GetOutput( ) ); + else + return( "MeshReader: output not correctly created." ); return( "" ); }