1 // =========================================================================
2 // @author Leonardo Florez Valencia
3 // @email florez-l@javeriana.edu.co
4 // =========================================================================
5 #ifndef __fpa__Common__Image__PathWriter__hxx__
6 #define __fpa__Common__Image__PathWriter__hxx__
10 // -------------------------------------------------------------------------
11 template< class _TPath >
12 const _TPath* fpa::Common::Image::PathWriter< _TPath >::
16 dynamic_cast< const TPath* >(
17 this->itk::ProcessObject::GetInput( 0 )
22 // -------------------------------------------------------------------------
23 template< class _TPath >
24 void fpa::Common::Image::PathWriter< _TPath >::
25 SetInput( const _TPath* path )
27 this->itk::ProcessObject::SetNthInput( 0, const_cast< TPath* >( path ) );
30 // -------------------------------------------------------------------------
31 template< class _TPath >
32 void fpa::Common::Image::PathWriter< _TPath >::
35 TPath* input = const_cast< TPath* >( this->GetInput( ) );
38 input->UpdateOutputInformation( );
39 input->UpdateOutputData( );
40 this->GenerateData( );
41 this->ReleaseInputs( );
46 // -------------------------------------------------------------------------
47 template< class _TPath >
48 fpa::Common::Image::PathWriter< _TPath >::
53 this->SetNumberOfRequiredInputs( 1 );
56 // -------------------------------------------------------------------------
57 template< class _TPath >
58 fpa::Common::Image::PathWriter< _TPath >::
63 // -------------------------------------------------------------------------
64 template< class _TPath >
65 void fpa::Common::Image::PathWriter< _TPath >::
68 const TPath* path = this->GetInput( );
70 // Write base information
71 std::stringstream out1, out2;
72 out1 << TPath::Dimension << std::endl;
73 typename TPath::TSpacing spa = path->GetSpacing( );
74 for( unsigned int d = 0; d < TPath::Dimension; ++d )
75 out1 << spa[ d ] << " ";
77 typename TPath::TDirection dir = path->GetDirection( );
78 for( unsigned int d = 0; d < TPath::Dimension; ++d )
79 for( unsigned int e = 0; e < TPath::Dimension; ++e )
80 out1 << dir[ d ][ e ] << " ";
82 typename TPath::TPoint ori = path->GetOrigin( );
83 for( unsigned int d = 0; d < TPath::Dimension; ++d )
84 out1 << ori[ d ] << " ";
88 unsigned int size = path->GetSize( );
89 out2 << size << std::endl;
90 for( unsigned int i = 0; i < path->GetSize( ); ++i )
92 typename TPath::TIndex v = path->GetVertex( i );
93 for( unsigned int d = 0; d < TPath::Dimension; ++d )
94 out2 << v[ d ] << " ";
99 std::ofstream file_stream( this->m_FileName.c_str( ), std::ofstream::binary );
102 << "Unable to write skeleton to \""
106 file_stream.write( out1.str( ).c_str( ), out1.str( ).size( ) );
109 #endif // __fpa__Common__Image__PathWriter__hxx__