exec( )
{
this->_updateWidgets( );
+ this->updateView( );
int ret = this->QDialog::exec( );
if( ret == 1 )
} // 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( )
} // 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( );
}
// -------------------------------------------------------------------------
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( );
#include "MeshReader.h"
#include <cpPlugins/Interface/Mesh.h>
+#include <cstring>
+
#include <vtkPolyData.h>
#include <vtkPolyDataReader.h>
+#include <vtkSTLReader.h>
// -------------------------------------------------------------------------
cpPlugins::IO::MeshReader::
// 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$
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." );