]> Creatis software - cpPlugins.git/blobdiff - lib/cpPlugins/Plugins/MeshReader.cxx
Image visualization objects updated
[cpPlugins.git] / lib / cpPlugins / Plugins / MeshReader.cxx
index 322e49c350fec9432404770150280b33b569d360..b7ce4ba88e3d5667232cef35c237d82a95854295 100644 (file)
@@ -4,6 +4,13 @@
 #include <cpPlugins/Extensions/DataStructures/QuadEdgeMesh.h>
 #include <cpPlugins/Extensions/IO/MeshReader.h>
 
+// -------------------------------------------------------------------------
+std::string cpPlugins::Plugins::MeshReader::
+GetClassName( ) const
+{
+  return( "cpPlugins::Plugins::MeshReader" );
+}
+
 // -------------------------------------------------------------------------
 cpPlugins::Plugins::MeshReader::
 MeshReader( )
@@ -12,10 +19,13 @@ MeshReader( )
   this->SetNumberOfOutputs( 1 );
   this->_MakeOutput< cpPlugins::Interface::Mesh >( 0 );
 
-  this->m_DefaultParameters[ "FileName" ] =
-    TParameter( "string", "no_file_name" );
-  this->m_DefaultParameters[ "PixelType" ] = TParameter( "type", "float" );
-  this->m_DefaultParameters[ "MeshDimension" ] = TParameter( "int", "3" );
+  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;
 }
 
 // -------------------------------------------------------------------------
@@ -24,27 +34,15 @@ cpPlugins::Plugins::MeshReader::
 {
 }
 
-// -------------------------------------------------------------------------
-std::string cpPlugins::Plugins::MeshReader::
-GetClassName( ) const
-{
-  return( "cpPlugins::Plugins::MeshReader" );
-}
-
 // -------------------------------------------------------------------------
 std::string cpPlugins::Plugins::MeshReader::
 _GenerateData( )
 {
-  TParameters::const_iterator dIt;
-
-  // Get image dimension
-  dIt = this->m_Parameters.find( "MeshDimension" );
-  if( dIt == this->m_Parameters.end( ) )
-    dIt = this->m_DefaultParameters.find( "MeshDimension" );
-
+  using namespace cpPlugins::Interface;
+  Parameters::TUint dim = this->m_Parameters.GetValueAsUint( "Dimension" );
   std::string r = "cpPlugins::Plugins::MeshReader: itk::Mesh dimension not supported.";
-  if( dIt->second.second == "3" ) r = this->_GD0< 3 >( );
-
+  if( dim == 3 )
+    r = this->_GD0< 3 >( );
   return( r );
 }
 
@@ -53,18 +51,11 @@ template< unsigned int D >
 std::string cpPlugins::Plugins::MeshReader::
 _GD0( )
 {
-  TParameters::const_iterator tIt, cIt;
-
-  // Get image pixel type
-  tIt = this->m_Parameters.find( "PixelType" );
-  if( tIt == this->m_Parameters.end( ) )
-    tIt = this->m_DefaultParameters.find( "PixelType" );
-
+  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( tIt->second.second == "float" )
-    r = this->_GD1< float, D >( );
-  else if( tIt->second.second == "double" )
-    r = this->_GD1< double, D >( );
+  if( pt == "float" )       r = this->_GD1< float, D >( );
+  else if( pt == "double" ) r = this->_GD1< double, D >( );
   return( r );
 }
 
@@ -73,26 +64,25 @@ template< class P, unsigned int D >
 std::string cpPlugins::Plugins::MeshReader::
 _GD1( )
 {
-  TParameters::const_iterator fIt;
-
   // Get filename
-  fIt = this->m_Parameters.find( "FileName" );
-  if( fIt == this->m_Parameters.end( ) )
-    fIt = this->m_DefaultParameters.find( "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_Reader.GetPointer( ) );
+    dynamic_cast< _TReader* >( this->m_RealProcessObject.GetPointer( ) );
   if( reader == NULL )
   {
-    this->m_Reader = _TReader::New( );
-    reader = dynamic_cast< _TReader* >( this->m_Reader.GetPointer( ) );
+    this->m_RealProcessObject = _TReader::New( );
+    reader =
+      dynamic_cast< _TReader* >( this->m_RealProcessObject.GetPointer( ) );
 
   } // fi
-  reader->SetFileName( fIt->second.second );
+  reader->SetFileName( fname );
   try
   {
     reader->Update( );