From: Leonardo Florez-Valencia Date: Tue, 2 Feb 2016 04:19:00 +0000 (-0500) Subject: ... X-Git-Tag: v0.1~254 X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=bf1c5140976e42a53f0860b2e8691d72ef70ff49;p=cpPlugins.git ... --- diff --git a/lib/cpPlugins/Interface/ParametersQtDialog.cxx b/lib/cpPlugins/Interface/ParametersQtDialog.cxx index 456704b..32cd8c4 100644 --- a/lib/cpPlugins/Interface/ParametersQtDialog.cxx +++ b/lib/cpPlugins/Interface/ParametersQtDialog.cxx @@ -65,6 +65,7 @@ int cpPlugins::Interface::ParametersQtDialog:: exec( ) { this->_updateWidgets( ); + this->updateView( ); int ret = this->QDialog::exec( ); if( ret == 1 ) @@ -268,6 +269,26 @@ updateView( ) } // rof } +// ------------------------------------------------------------------------- +void cpPlugins::Interface::ParametersQtDialog:: +_addButtons( ) +{ + // Add buttons + this->m_Buttons = new QDialogButtonBox( + QDialogButtonBox::Ok | QDialogButtonBox::Cancel + ); + this->connect( + this->m_Buttons, SIGNAL( accepted( ) ), this, SLOT( accept( ) ) + ); + this->connect( + this->m_Buttons, SIGNAL( rejected( ) ), this, SLOT( reject( ) ) + ); + this->m_ToolsLayout->addWidget( this->m_Buttons ); + + this->updateView( ); + this->m_WidgetsUpdated = true; +} + // ------------------------------------------------------------------------- void cpPlugins::Interface::ParametersQtDialog:: _updateWidgets( ) @@ -512,21 +533,8 @@ _updateWidgets( ) } // rof - // Add buttons - this->m_Buttons = new QDialogButtonBox( - QDialogButtonBox::Ok | QDialogButtonBox::Cancel - ); - this->connect( - this->m_Buttons, SIGNAL( accepted( ) ), this, SLOT( accept( ) ) - ); - this->connect( - this->m_Buttons, SIGNAL( rejected( ) ), this, SLOT( reject( ) ) - ); - this->m_ToolsLayout->addWidget( this->m_Buttons ); - // Update values - this->updateView( ); - this->m_WidgetsUpdated = true; + this->_addButtons( ); } // ------------------------------------------------------------------------- diff --git a/lib/cpPlugins/Interface/ParametersQtDialog.h b/lib/cpPlugins/Interface/ParametersQtDialog.h index 421f707..04b76ed 100644 --- a/lib/cpPlugins/Interface/ParametersQtDialog.h +++ b/lib/cpPlugins/Interface/ParametersQtDialog.h @@ -36,11 +36,12 @@ namespace cpPlugins virtual int exec( ); - void updateParameters( ); - void updateView( ); + virtual void updateParameters( ); + virtual void updateView( ); protected: - void _updateWidgets( ); + virtual void _addButtons( ); + virtual void _updateWidgets( ); protected slots: virtual void _dlg_OpenSingleFile( ); diff --git a/lib/cpPlugins/Plugins/IO/MeshReader.cxx b/lib/cpPlugins/Plugins/IO/MeshReader.cxx index 60bb57d..8dce561 100644 --- a/lib/cpPlugins/Plugins/IO/MeshReader.cxx +++ b/lib/cpPlugins/Plugins/IO/MeshReader.cxx @@ -1,8 +1,11 @@ #include "MeshReader.h" #include +#include + #include #include +#include // ------------------------------------------------------------------------- cpPlugins::IO::MeshReader:: @@ -67,16 +70,41 @@ _GD1( ) // Get filename std::string fname = this->m_Parameters->GetOpenFileName( "FileName" ); - vtkPolyDataReader* pdr = this->_CreateVTK< vtkPolyDataReader >( ); - pdr->SetFileName( fname.c_str( ) ); - pdr->Update( ); + // Get file extension + std::istringstream fname_str( fname ); + std::string token, ext; + while( std::getline( fname_str, token, '.' ) ) + ext = token; + std::transform( ext.begin( ), ext.end( ), ext.begin( ), tolower ); + + // Real read + if( ext == "stl" ) + { + vtkSTLReader* stlr = this->_CreateVTK< vtkSTLReader >( ); + stlr->SetFileName( fname.c_str( ) ); + stlr->Update( ); + + auto out = this->GetOutputData< cpPlugins::Interface::Mesh >( "Output" ); + if( out != NULL ) + out->SetVTK( stlr->GetOutput( ) ); + else + return( "MeshReader: output not correctly created." ); + return( "" ); + } + else if( ext == "vtk" ) + { + vtkPolyDataReader* pdr = this->_CreateVTK< vtkPolyDataReader >( ); + pdr->SetFileName( fname.c_str( ) ); + pdr->Update( ); + + auto out = this->GetOutputData< cpPlugins::Interface::Mesh >( "Output" ); + if( out != NULL ) + out->SetVTK( pdr->GetOutput( ) ); + else + return( "MeshReader: output not correctly created." ); + return( "" ); - auto out = this->GetOutputData< cpPlugins::Interface::Mesh >( "Output" ); - if( out != NULL ) - out->SetVTK( pdr->GetOutput( ) ); - else - return( "MeshReader: output not correctly created." ); - return( "" ); + } // fi } // eof - $RCSfile$ diff --git a/lib/cpPlugins/Plugins/IO/MeshWriter.cxx b/lib/cpPlugins/Plugins/IO/MeshWriter.cxx index 7f0bba0..b0b7227 100644 --- a/lib/cpPlugins/Plugins/IO/MeshWriter.cxx +++ b/lib/cpPlugins/Plugins/IO/MeshWriter.cxx @@ -39,6 +39,7 @@ _GenerateData( ) vtkPolyDataWriter* pdw = this->_CreateVTK< vtkPolyDataWriter >( ); pdw->SetInputData( i ); pdw->SetFileName( fname.c_str( ) ); + pdw->SetFileTypeToBinary( ); pdw->Update( ); if( pdw->GetErrorCode( ) != 0 ) return( "MeshWriter: someting wrong happened." );