From 5e682cefc1d781eacc867d103891f77f79fb9bab Mon Sep 17 00:00:00 2001 From: =?utf8?q?Leonardo=20Fl=C3=B3rez-Valencia?= Date: Sun, 5 Feb 2017 15:49:31 -0500 Subject: [PATCH] ... --- .../Algorithms/BezierCurveFunction.h | 2 +- plugins/IO/ImageJSkeletonWriter.cxx | 104 ++++++++++++++++++ plugins/IO/ImageJSkeletonWriter.h | 28 +++++ 3 files changed, 133 insertions(+), 1 deletion(-) create mode 100644 plugins/IO/ImageJSkeletonWriter.cxx create mode 100644 plugins/IO/ImageJSkeletonWriter.h diff --git a/lib/cpExtensions/Algorithms/BezierCurveFunction.h b/lib/cpExtensions/Algorithms/BezierCurveFunction.h index 65c3af8..b8234a9 100644 --- a/lib/cpExtensions/Algorithms/BezierCurveFunction.h +++ b/lib/cpExtensions/Algorithms/BezierCurveFunction.h @@ -5,7 +5,7 @@ #ifndef __CPEXTENSIONS__ALGORITHMS__BEZIERCURVEFUNCTION__H__ #define __CPEXTENSIONS__ALGORITHMS__BEZIERCURVEFUNCTION__H__ -#include +// TODO: #include #include #include #include diff --git a/plugins/IO/ImageJSkeletonWriter.cxx b/plugins/IO/ImageJSkeletonWriter.cxx new file mode 100644 index 0000000..482000f --- /dev/null +++ b/plugins/IO/ImageJSkeletonWriter.cxx @@ -0,0 +1,104 @@ +#include +#include + +#include +#include +#include + +#ifdef cpPlugins_QT4 +# include +#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 index 0000000..6adffbf --- /dev/null +++ b/plugins/IO/ImageJSkeletonWriter.h @@ -0,0 +1,28 @@ +#ifndef __cpPluginsIO__ImageJSkeletonWriter__h__ +#define __cpPluginsIO__ImageJSkeletonWriter__h__ + +#include +#include + +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$ -- 2.45.0