--- /dev/null
+#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$
--- /dev/null
+#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$