]> Creatis software - cpPlugins.git/blobdiff - lib/cpPlugins/Plugins/MeshReader.cxx
...
[cpPlugins.git] / lib / cpPlugins / Plugins / MeshReader.cxx
index 5338c32b3424ebd1464be2406a7144e682fb4042..0528e6cd4b15d35507e630751f5d0350a77be0c3 100644 (file)
@@ -7,7 +7,8 @@
 // -------------------------------------------------------------------------
 cpPlugins::Plugins::MeshReader::
 MeshReader( )
-  : Superclass( )
+  : Superclass( ),
+    m_Reader( NULL )
 {
   this->m_ClassName = "cpPlugins::MeshReader";
   this->m_ClassCategory = "MeshReader";
@@ -28,6 +29,8 @@ MeshReader( )
 cpPlugins::Plugins::MeshReader::
 ~MeshReader( )
 {
+  if( this->m_Reader != NULL )
+    this->m_Reader = NULL;
 }
 
 // -------------------------------------------------------------------------
@@ -37,7 +40,9 @@ _GenerateData( )
   using namespace cpPlugins::Interface;
   Parameters::TUint dim = this->m_Parameters.GetValueAsUint( "Dimension" );
   std::string r = "MeshReader: Mesh dimension not supported.";
-  if( dim == 3 )
+  if( dim == 2 )
+    r = this->_GD0< 2 >( );
+  else if( dim == 3 )
     r = this->_GD0< 3 >( );
   return( r );
 }
@@ -72,7 +77,13 @@ _GD1( )
   this->m_Reader = pdr;
   pdr->SetFileName( fname.c_str( ) );
   pdr->Update( );
-  this->m_Outputs[ 0 ]->SetVTKDataObject( pdr->GetOutput( ) );
+
+  cpPlugins::Interface::Mesh* out =
+    this->_Output< cpPlugins::Interface::Mesh >( 0 );
+  if( out != NULL )
+    out->SetVTKMesh( pdr->GetOutput( ) );
+  else
+    return( "MeshReader: output not correctly created." );
   return( "" );
 }