]> Creatis software - cpPlugins.git/blobdiff - plugins/cpExtensions/SkeletonReader.cxx
yet another refactoring
[cpPlugins.git] / plugins / cpExtensions / SkeletonReader.cxx
diff --git a/plugins/cpExtensions/SkeletonReader.cxx b/plugins/cpExtensions/SkeletonReader.cxx
new file mode 100644 (file)
index 0000000..f62ff69
--- /dev/null
@@ -0,0 +1,93 @@
+#include <cpExtensions/SkeletonReader.h>
+#include <cpInstances/DataObjects/Skeleton.h>
+
+#include <cpExtensions/DataStructures/Skeleton.h>
+#include <cpExtensions/Algorithms/SkeletonReader.h>
+#include <cpPlugins/QT/OpenFileDialog.h>
+
+#ifdef cpPlugins_QT4
+#  include <QApplication>
+#endif // cpPlugins_QT4
+
+// -------------------------------------------------------------------------
+QDialog* cpPluginscpExtensions::SkeletonReader::
+CreateQDialog( )
+{
+#ifdef cpPlugins_QT4
+  cpPlugins::QT::OpenFileDialog* dlg = NULL;
+  if( QApplication::instance( ) != NULL )
+  {
+    dlg = new cpPlugins::QT::OpenFileDialog( );
+    dlg->SetParameters( &( this->m_Parameters ), "FileName" );
+
+  } // fi
+  return( dlg );
+#else // cpPlugins_QT4
+  return( NULL );
+#endif // cpPlugins_QT4
+}
+
+// -------------------------------------------------------------------------
+cpPluginscpExtensions::SkeletonReader::
+SkeletonReader( )
+  : Superclass( )
+{
+  this->_ConfigureOutput< cpInstances::Skeleton >( "Output" );
+  this->m_Parameters.ConfigureAsOpenFileName( "FileName", "" );
+  this->m_Parameters.SetAcceptedFileExtensions(
+    "FileName",
+    "Skeleton files (*.txt)"
+    );
+}
+
+// -------------------------------------------------------------------------
+cpPluginscpExtensions::SkeletonReader::
+~SkeletonReader( )
+{
+}
+
+// -------------------------------------------------------------------------
+void cpPluginscpExtensions::SkeletonReader::
+_GenerateData( )
+{
+  std::string success = "";
+#ifdef cpPlugins_CONFIG_PROCESS_DIMENSIONS_1
+  success = this->_GD0< 1 >( );
+#endif // cpPlugins_CONFIG_PROCESS_DIMENSIONS_1
+#ifdef cpPlugins_CONFIG_PROCESS_DIMENSIONS_2
+  if( success != "" ) success = this->_GD0< 2 >( );
+#endif // cpPlugins_CONFIG_PROCESS_DIMENSIONS_2
+#ifdef cpPlugins_CONFIG_PROCESS_DIMENSIONS_3
+  if( success != "" ) success = this->_GD0< 3 >( );
+#endif // cpPlugins_CONFIG_PROCESS_DIMENSIONS_3
+#ifdef cpPlugins_CONFIG_PROCESS_DIMENSIONS_4
+  if( success != "" ) success = this->_GD0< 4 >( );
+#endif // cpPlugins_CONFIG_PROCESS_DIMENSIONS_4
+  if( success != "" )
+    this->_Error( success );
+}
+
+// -------------------------------------------------------------------------
+template< unsigned int _VDim >
+std::string cpPluginscpExtensions::SkeletonReader::
+_GD0( )
+{
+  typedef cpExtensions::DataStructures::Skeleton< _VDim > _TSkeleton;
+  typedef cpExtensions::Algorithms::SkeletonReader< _TSkeleton > _TReader;
+
+  auto filter = this->_CreateITK< _TReader >( );
+  filter->SetFileName( this->m_Parameters.GetOpenFileName( "FileName" ) );
+  try
+  {
+    filter->Update( );
+  }
+  catch( std::exception& err )
+  {
+    return( err.what( ) );
+
+  } // yrt
+  this->GetOutput( "Output" )->SetITK( filter->GetOutput( ) );
+  return( "" );
+}
+
+// eof - $RCSfile$