]> Creatis software - cpPlugins.git/commitdiff
...
authorLeonardo Flórez-Valencia <leonardo.florez@gmail.com>
Sun, 5 Feb 2017 20:49:31 +0000 (15:49 -0500)
committerLeonardo Flórez-Valencia <leonardo.florez@gmail.com>
Sun, 5 Feb 2017 20:49:31 +0000 (15:49 -0500)
lib/cpExtensions/Algorithms/BezierCurveFunction.h
plugins/IO/ImageJSkeletonWriter.cxx [new file with mode: 0644]
plugins/IO/ImageJSkeletonWriter.h [new file with mode: 0644]

index 65c3af8be41a7537554423efe6bb878075422c6e..b8234a9f05f71919f147d40dedf4a27a73ef43d2 100644 (file)
@@ -5,7 +5,7 @@
 #ifndef __CPEXTENSIONS__ALGORITHMS__BEZIERCURVEFUNCTION__H__
 #define __CPEXTENSIONS__ALGORITHMS__BEZIERCURVEFUNCTION__H__
 
-#include <cpExtensions/Config.h>
+// TODO: #include <cpExtensions/Config.h>
 #include <vector>
 #include <itkFunctionBase.h>
 #include <itkMatrix.h>
diff --git a/plugins/IO/ImageJSkeletonWriter.cxx b/plugins/IO/ImageJSkeletonWriter.cxx
new file mode 100644 (file)
index 0000000..482000f
--- /dev/null
@@ -0,0 +1,104 @@
+#include <IO/ImageJSkeletonWriter.h>
+#include <cpPlugins/QT/SaveFileDialog.h>
+
+#include <cpPluginsExtensions/Skeleton.h>
+#include <cpExtensions/DataStructures/Skeleton.h>
+#include <cpExtensions/Utility.h>
+
+#ifdef cpPlugins_QT4
+#  include <QApplication>
+#endif // cpPlugins_QT4
+
+// -------------------------------------------------------------------------
+QDialog* cpPluginsIO::ImageJSkeletonWriter::
+CreateQDialog( )
+{
+#ifdef cpPlugins_QT4
+  cpPlugins::QT::SaveFileDialog* dlg = NULL;
+  if( QApplication::instance( ) != NULL )
+  {
+    dlg = new cpPlugins::QT::SaveFileDialog( );
+    dlg->SetParameters( &( this->m_Parameters ), "FileName" );
+
+  } // fi
+  return( dlg );
+#else // cpPlugins_QT4
+  return( NULL );
+#endif // cpPlugins_QT4
+}
+
+// -------------------------------------------------------------------------
+cpPluginsIO::ImageJSkeletonWriter::
+ImageJSkeletonWriter( )
+  : Superclass( )
+{
+  typedef cpPluginsExtensions::Skeleton _TSkeleton;
+  this->_ConfigureInput< _TSkeleton >( "Input", true, false );
+
+  this->m_Parameters.ConfigureAsSaveFileName( "FileName", "" );
+  this->m_Parameters.SetAcceptedFileExtensions(
+    "FileName",
+    "ImageJ files (*.txt)"
+    );
+}
+
+// -------------------------------------------------------------------------
+cpPluginsIO::ImageJSkeletonWriter::
+~ImageJSkeletonWriter( )
+{
+}
+
+// -------------------------------------------------------------------------
+void cpPluginsIO::ImageJSkeletonWriter::
+_GenerateData( )
+{
+  auto o = this->GetInputData( "Input" );
+  cpPlugins_Demangle_Skeleton_All_1( o, _GD0 )
+    this->_Error( "Invalid input skeleton type." );
+}
+
+// -------------------------------------------------------------------------
+template< class _TSkeleton >
+void cpPluginsIO::ImageJSkeletonWriter::
+_GD0( _TSkeleton* skeleton )
+{
+  std::stringstream data;
+  unsigned long id = 1;
+
+  auto mIt = skeleton->BeginEdgesRows( );
+  for( ; mIt != skeleton->EndEdgesRows( ); ++mIt )
+  {
+    auto rIt = mIt->second.begin( );
+    for( ; rIt != mIt->second.end( ); ++rIt )
+    {
+      auto eIt = rIt->second.begin( );
+      for( ; eIt != rIt->second.end( ); ++eIt )
+      {
+        auto path = *eIt;
+        auto p0 = path->GetSmoothPoint( 0 );
+        auto p1 = path->GetSmoothPoint( 1 );
+        double length = p1.EuclideanDistanceTo( p0 );
+        data
+          << id << "\t1\t" << length << "\t"
+          << p0[ 0 ] << "\t" << p0[ 1 ] << "\t"<< p0[ 2 ] << "\t"
+          << p1[ 0 ] << "\t" << p1[ 1 ] << "\t"<< p1[ 2 ] << "\t"
+          << p1.EuclideanDistanceTo( p0 ) << std::endl;
+        id++;
+
+      } // rof
+
+    } // rof
+
+  } // rof
+
+  if(
+    !(
+      cpExtensions::Write(
+        data.str( ), this->m_Parameters.GetSaveFileName( "FileName" )
+        )
+      )
+    )
+    this->_Error( "Could not write on ImageJ file." );
+}
+
+// eof - $RCSfile$
diff --git a/plugins/IO/ImageJSkeletonWriter.h b/plugins/IO/ImageJSkeletonWriter.h
new file mode 100644 (file)
index 0000000..6adffbf
--- /dev/null
@@ -0,0 +1,28 @@
+#ifndef __cpPluginsIO__ImageJSkeletonWriter__h__
+#define __cpPluginsIO__ImageJSkeletonWriter__h__
+
+#include <cpPluginsIO_Export.h>
+#include <cpPlugins/BaseObjects/ProcessObject.h>
+
+namespace cpPluginsIO
+{
+  /**
+   */
+  class cpPluginsIO_EXPORT ImageJSkeletonWriter
+    : public cpPlugins::BaseObjects::ProcessObject
+  {
+    cpPluginsObject( ImageJSkeletonWriter, cpPlugins::BaseObjects::ProcessObject, IO );
+
+  public:
+    virtual QDialog* CreateQDialog( ) cpPlugins_OVERRIDE;
+
+  protected:
+    template< class _TSkeleton >
+    inline void _GD0( _TSkeleton* skeleton );
+  };
+
+} // ecapseman
+
+#endif // __cpPluginsIO__ImageJSkeletonWriter__h__
+
+// eof - $RCSfile$