#ifndef __FPA__IO__MATRIXVALUESCONTAINERWRITER__HXX__ #define __FPA__IO__MATRIXVALUESCONTAINERWRITER__HXX__ #include #include // ------------------------------------------------------------------------- template< class T > void fpa::IO::MatrixValuesContainerWriter< T >:: SetInput( const T* input ) { this->itk::ProcessObject::SetNthInput( 0, const_cast< T* >( input ) ); } // ------------------------------------------------------------------------- template< class T > T* fpa::IO::MatrixValuesContainerWriter< T >:: GetInput( ) { return( dynamic_cast< T* >( this->itk::ProcessObject::GetInput( 0 ) ) ); } // ------------------------------------------------------------------------- template< class T > const T* fpa::IO::MatrixValuesContainerWriter< T >:: GetInput( ) const { return( dynamic_cast< const T* >( this->itk::ProcessObject::GetInput( 0 ) ) ); } // ------------------------------------------------------------------------- template< class T > void fpa::IO::MatrixValuesContainerWriter< T >:: Update( ) { T* input = this->GetInput( ); if( input != NULL ) { input->UpdateOutputInformation( ); input->UpdateOutputData( ); this->GenerateData( ); this->ReleaseInputs( ); } // fi } // ------------------------------------------------------------------------- template< class T > fpa::IO::MatrixValuesContainerWriter< T >:: MatrixValuesContainerWriter( ) : Superclass( ), m_FileName( "" ) { this->SetNumberOfRequiredInputs( 1 ); } // ------------------------------------------------------------------------- template< class T > fpa::IO::MatrixValuesContainerWriter< T >:: ~MatrixValuesContainerWriter( ) { } // ------------------------------------------------------------------------- template< class T > void fpa::IO::MatrixValuesContainerWriter< T >:: GenerateData( ) { const T* input = this->GetInput( ); std::ofstream out( this->m_FileName.c_str( ) ); if( !out ) { itkExceptionMacro( << "Error opening file to write a minimum spanning tree: \"" << this->m_FileName << "\"" ); return; } // fi out << T::TIndex::Dimension << std::endl; const typename T::TDecorated& real_input = input->Get( ); out << real_input.size( ) << std::endl; typename T::TDecorated::const_iterator cIt = real_input.begin( ); for( ; cIt != real_input.end( ); ++cIt ) { out << cIt->second.size( ) << " "; for( unsigned int d = 0; d < T::TIndex::Dimension; ++d ) out << ( cIt->first )[ d ] << " "; typename T::TDecorated::value_type::second_type::const_iterator rIt = cIt->second.begin( ); for( ; rIt != cIt->second.end( ); ++rIt ) { for( unsigned int d = 0; d < T::TIndex::Dimension; ++d ) out << ( rIt->first )[ d ] << " "; out << rIt->second << std::endl; } // rof } // rof out.close( ); } #endif // __FPA__IO__MATRIXVALUESCONTAINERWRITER__HXX__ // eof - $RCSfile$