1 #ifndef __FPA__IO__MINIMUMSPANNINGTREEWRITER__HXX__
2 #define __FPA__IO__MINIMUMSPANNINGTREEWRITER__HXX__
7 // -------------------------------------------------------------------------
9 void fpa::IO::MinimumSpanningTreeWriter< T >::
10 SetInput( const T* input )
12 this->itk::ProcessObject::SetNthInput( 0, const_cast< T* >( input ) );
15 // -------------------------------------------------------------------------
17 T* fpa::IO::MinimumSpanningTreeWriter< T >::
20 return( dynamic_cast< T* >( this->itk::ProcessObject::GetInput( 0 ) ) );
23 // -------------------------------------------------------------------------
25 const T* fpa::IO::MinimumSpanningTreeWriter< T >::
29 dynamic_cast< const T* >( this->itk::ProcessObject::GetInput( 0 ) )
33 // -------------------------------------------------------------------------
35 void fpa::IO::MinimumSpanningTreeWriter< T >::
38 T* input = this->GetInput( );
41 input->UpdateOutputInformation( );
42 input->UpdateOutputData( );
43 this->GenerateData( );
44 this->ReleaseInputs( );
49 // -------------------------------------------------------------------------
51 fpa::IO::MinimumSpanningTreeWriter< T >::
52 MinimumSpanningTreeWriter( )
56 this->SetNumberOfRequiredInputs( 1 );
59 // -------------------------------------------------------------------------
61 fpa::IO::MinimumSpanningTreeWriter< T >::
62 ~MinimumSpanningTreeWriter( )
66 // -------------------------------------------------------------------------
68 void fpa::IO::MinimumSpanningTreeWriter< T >::
71 const T* input = this->GetInput( );
73 std::ofstream out( this->m_FileName.c_str( ) );
77 << "Error opening file to write a minimum spanning tree: \""
85 out << T::TVertex::Dimension << std::endl;
87 const typename T::TCollisions& collisions = input->GetCollisions( );
88 unsigned long nSeeds = collisions.size( );
89 out << nSeeds << std::endl;
90 for( unsigned long i = 0; i < nSeeds; ++i )
92 for( unsigned long j = 0; j < nSeeds; ++j )
93 out << collisions[ i ][ j ].second << " ";
98 const typename T::TDecorated& real_input = input->Get( );
99 out << real_input.size( ) << std::endl;
101 typename T::TDecorated::const_iterator iIt = real_input.begin( );
102 iIt != real_input.end( );
106 for( unsigned int d = 0; d < T::TVertex::Dimension; ++d )
107 out << iIt->first[ d ] << " ";
108 for( unsigned int d = 0; d < T::TVertex::Dimension; ++d )
109 out << iIt->second.first[ d ] << " ";
110 out << iIt->second.second << std::endl;
116 #endif // __FPA__IO__MINIMUMSPANNINGTREEWRITER__HXX__