+++ /dev/null
-// -------------------------------------------------------------------------
-// @author Leonardo Florez-Valencia (florez-l@javeriana.edu.co)
-// -------------------------------------------------------------------------
-
-#ifndef __cpExtensions__Algorithms__SkeletonWriter__hxx__
-#define __cpExtensions__Algorithms__SkeletonWriter__hxx__
-
-#include <cpExtensions/Utility.h>
-
-// -------------------------------------------------------------------------
-template< class _TSkeleton >
-const _TSkeleton* cpExtensions::Algorithms::SkeletonWriter< _TSkeleton >::
-GetInput( ) const
-{
- return(
- dynamic_cast< const TSkeleton* >(
- this->itk::ProcessObject::GetInput( 0 )
- )
- );
-}
-
-// -------------------------------------------------------------------------
-template< class _TSkeleton >
-void cpExtensions::Algorithms::SkeletonWriter< _TSkeleton >::
-SetInput( const _TSkeleton* skeleton )
-{
- this->itk::ProcessObject::SetNthInput(
- 0, const_cast< TSkeleton* >( skeleton )
- );
-}
-
-// -------------------------------------------------------------------------
-template< class _TSkeleton >
-void cpExtensions::Algorithms::SkeletonWriter< _TSkeleton >::
-Update( )
-{
- TSkeleton* input = const_cast< TSkeleton* >( this->GetInput( ) );
- if( input != NULL )
- {
- input->UpdateOutputInformation( );
- input->UpdateOutputData( );
- this->GenerateData( );
- this->ReleaseInputs( );
-
- } // fi
-}
-
-// -------------------------------------------------------------------------
-template< class _TSkeleton >
-cpExtensions::Algorithms::SkeletonWriter< _TSkeleton >::
-SkeletonWriter( )
- : Superclass( ),
- m_FileName( "" )
-{
- this->SetNumberOfRequiredInputs( 1 );
-}
-
-// -------------------------------------------------------------------------
-template< class _TSkeleton >
-cpExtensions::Algorithms::SkeletonWriter< _TSkeleton >::
-~SkeletonWriter( )
-{
-}
-
-// -------------------------------------------------------------------------
-template< class _TSkeleton >
-void cpExtensions::Algorithms::SkeletonWriter< _TSkeleton >::
-GenerateData( )
-{
- const TSkeleton* sk = this->GetInput( );
- std::stringstream out;
- out << TSkeleton::Dimension << std::endl;
-
- // Write
- auto mIt = sk->BeginEdgesRows( );
- for( ; mIt != sk->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;
- unsigned int size = path->GetSize( );
- auto spa = path->GetSpacing( );
- auto ori = path->GetOrigin( );
- auto dir = path->GetDirection( );
- out << size << std::endl;
- for( unsigned int d = 0; d < TSkeleton::Dimension; ++d )
- out << spa[ d ] << " ";
- out << std::endl;
- for( unsigned int d = 0; d < TSkeleton::Dimension; ++d )
- out << ori[ d ] << " ";
- out << std::endl;
- for( unsigned int d = 0; d < TSkeleton::Dimension; ++d )
- for( unsigned int e = 0; e < TSkeleton::Dimension; ++e )
- out << dir[ d ][ e ] << " ";
- out << std::endl;
-
- for( unsigned int i = 0; i < path->GetSize( ); ++i )
- {
- auto v = path->GetVertex( i );
- for( unsigned int d = 0; d < TSkeleton::Dimension; ++d )
- out << v[ d ] << " ";
-
- } // rof
- out << std::endl;
-
- } // rof
-
- } // rof
-
- } // rof
- out << "0" << std::endl;
-
- if( !( cpExtensions::Write( out.str( ), this->m_FileName ) ) )
- itkExceptionMacro(
- << "Unable to write skeleton to \""
- << this->m_FileName
- << "\""
- );
-}
-
-#endif // __cpExtensions__Algorithms__SkeletonWriter__hxx__
-
-// eof - $RCSfile$