]> Creatis software - cpPlugins.git/blobdiff - plugins/ITKIO/ImageReader.cxx
...
[cpPlugins.git] / plugins / ITKIO / ImageReader.cxx
index 64d63a2b3dd4569c0305b7c55a80d7b914a1bf73..90b032fc2fedfc01439bac24aff94887cbabbcf9 100644 (file)
@@ -1,5 +1,5 @@
 #include <ITKIO/ImageReader.h>
-#include <cpInstances/Image.h>
+#include <cpInstances/DataObjects/Image.h>
 #include <cpPlugins/QT/OpenFileDialog.h>
 
 #define ITKIOImageBase_HIDDEN
@@ -34,7 +34,7 @@ cpPluginsITKIO::ImageReader::
 ImageReader( )
   : Superclass( )
 {
-  this->_ConfigureOutput< cpInstances::Image >( "Output" );
+  this->_ConfigureOutput< cpInstances::DataObjects::Image >( "Output" );
   this->m_Parameters.Clear( );
   this->m_Parameters.ConfigureAsOpenFileNameList( "FileNames" );
   this->m_Parameters.SetAcceptedFileExtensions(
@@ -55,12 +55,18 @@ _GenerateData( )
 {
   // Get filenames
   auto fnames = this->m_Parameters.GetOpenFileNameList( "FileNames" );
+  std::string fname = "";
   if( fnames.size( ) > 1 )
   {
     std::stringstream fname_str;
     fname_str << fnames[ 0 ] << cpPlugins_PATH_SEPARATOR << fnames[ 1 ];
-    std::string fname = fname_str.str( );
+    fname = fname_str.str( );
+  }
+  else if( fnames.size( ) == 1 )
+    fname = fnames[ 0 ];
 
+  if( fname != "" )
+  {
     // Guess image properties
     itk::ImageIOBase::Pointer io =
       itk::ImageIOFactory::CreateImageIO(
@@ -72,18 +78,18 @@ _GenerateData( )
       io->ReadImageInformation( );
       bool success = false;
       unsigned int dim = io->GetNumberOfDimensions( );
-#ifdef cpPlugins_CONFIG_PROCESS_DIMENSIONS_1
+#ifdef cpPlugins_PROCESS_DIMS_1
       if( dim == 1 ) success = this->_GD0< 1 >( io );
-#endif // cpPlugins_CONFIG_PROCESS_DIMENSIONS_1
-#ifdef cpPlugins_CONFIG_PROCESS_DIMENSIONS_2
+#endif // cpPlugins_PROCESS_DIMS_1
+#ifdef cpPlugins_PROCESS_DIMS_2
       if( dim == 2 ) success = this->_GD0< 2 >( io );
-#endif // cpPlugins_CONFIG_PROCESS_DIMENSIONS_2
-#ifdef cpPlugins_CONFIG_PROCESS_DIMENSIONS_3
+#endif // cpPlugins_PROCESS_DIMS_2
+#ifdef cpPlugins_PROCESS_DIMS_3
       if( dim == 3 ) success = this->_GD0< 3 >( io );
-#endif // cpPlugins_CONFIG_PROCESS_DIMENSIONS_3
-#ifdef cpPlugins_CONFIG_PROCESS_DIMENSIONS_4
+#endif // cpPlugins_PROCESS_DIMS_3
+#ifdef cpPlugins_PROCESS_DIMS_4
       if( dim == 4 ) success = this->_GD0< 4 >( io );
-#endif // cpPlugins_CONFIG_PROCESS_DIMENSIONS_4
+#endif // cpPlugins_PROCESS_DIMS_4
       if( !success )
         this->_Error( "Image dimension not supported." );
     }
@@ -210,10 +216,13 @@ _GD1( itk::ImageIOBase* io )
 
   // Get filenames
   auto fnames = this->m_Parameters.GetOpenFileNameList( "FileNames" );
-  if( fnames.size( ) == 2 )
+  if( fnames.size( ) == 1 || fnames.size( ) == 2 )
   {
     std::stringstream fname_str;
-    fname_str << fnames[ 0 ] << cpPlugins_PATH_SEPARATOR << fnames[ 1 ];
+    if( fnames.size( ) == 1 )
+      fname_str << fnames[ 0 ];
+    else
+      fname_str << fnames[ 0 ] << cpPlugins_PATH_SEPARATOR << fnames[ 1 ];
 
     auto f = this->_CreateITK< itk::ImageFileReader< _TImage > >( );
     f->SetFileName( fname_str.str( ) );