1 #ifndef __FPA__IO__MATRIXVALUESCONTAINERWRITER__HXX__
2 #define __FPA__IO__MATRIXVALUESCONTAINERWRITER__HXX__
7 // -------------------------------------------------------------------------
9 void fpa::IO::MatrixValuesContainerWriter< T >::
10 SetInput( const T* input )
12 this->itk::ProcessObject::SetNthInput( 0, const_cast< T* >( input ) );
15 // -------------------------------------------------------------------------
17 T* fpa::IO::MatrixValuesContainerWriter< T >::
20 return( dynamic_cast< T* >( this->itk::ProcessObject::GetInput( 0 ) ) );
23 // -------------------------------------------------------------------------
25 const T* fpa::IO::MatrixValuesContainerWriter< T >::
29 dynamic_cast< const T* >( this->itk::ProcessObject::GetInput( 0 ) )
33 // -------------------------------------------------------------------------
35 void fpa::IO::MatrixValuesContainerWriter< T >::
38 T* input = this->GetInput( );
41 input->UpdateOutputInformation( );
42 input->UpdateOutputData( );
43 this->GenerateData( );
44 this->ReleaseInputs( );
49 // -------------------------------------------------------------------------
51 fpa::IO::MatrixValuesContainerWriter< T >::
52 MatrixValuesContainerWriter( )
56 this->SetNumberOfRequiredInputs( 1 );
59 // -------------------------------------------------------------------------
61 fpa::IO::MatrixValuesContainerWriter< T >::
62 ~MatrixValuesContainerWriter( )
66 // -------------------------------------------------------------------------
68 void fpa::IO::MatrixValuesContainerWriter< 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::TIndex::Dimension << std::endl;
87 const typename T::TDecorated& real_input = input->Get( );
88 out << real_input.size( ) << std::endl;
89 typename T::TDecorated::const_iterator cIt = real_input.begin( );
90 for( ; cIt != real_input.end( ); ++cIt )
92 out << cIt->second.size( ) << " ";
93 for( unsigned int d = 0; d < T::TIndex::Dimension; ++d )
94 out << ( cIt->first )[ d ] << " ";
96 typename T::TDecorated::value_type::second_type::const_iterator rIt =
98 for( ; rIt != cIt->second.end( ); ++rIt )
100 for( unsigned int d = 0; d < T::TIndex::Dimension; ++d )
101 out << ( rIt->first )[ d ] << " ";
102 out << rIt->second << std::endl;
110 #endif // __FPA__IO__MATRIXVALUESCONTAINERWRITER__HXX__