#ifndef __FPA__IO__UNIQUEVALUESCONTAINERREADER__HXX__ #define __FPA__IO__UNIQUEVALUESCONTAINERREADER__HXX__ #include // ------------------------------------------------------------------------- template< class T > T* fpa::IO::UniqueValuesContainerReader< T >:: GetOutput( ) { return( itkDynamicCastInDebugMode< T* >( this->GetPrimaryOutput( ) ) ); } // ------------------------------------------------------------------------- template< class T > void fpa::IO::UniqueValuesContainerReader< T >:: Update( ) { this->GenerateData( ); } // ------------------------------------------------------------------------- template< class T > fpa::IO::UniqueValuesContainerReader< T >:: UniqueValuesContainerReader( ) : Superclass( ), m_FileName( "" ) { this->itk::ProcessObject::SetNumberOfRequiredOutputs( 1 ); this->itk::ProcessObject::SetNthOutput( 0, T::New( ) ); } // ------------------------------------------------------------------------- template< class T > fpa::IO::UniqueValuesContainerReader< T >:: ~UniqueValuesContainerReader( ) { } // ------------------------------------------------------------------------- template< class T > void fpa::IO::UniqueValuesContainerReader< T >:: GenerateData( ) { T* output = this->GetOutput( ); output->Clear( ); std::ifstream in( this->m_FileName.c_str( ) ); if( !in ) { itkExceptionMacro( << "Error opening file to read a minimum spanning tree: \"" << this->m_FileName << "\"" ); return; } // fi unsigned int dim; unsigned long nVertices; in >> dim >> nVertices; for( unsigned long vId = 0; vId < nVertices; ++vId ) { typename T::TValue v; for( unsigned int d = 0; d < dim; ++d ) { long val; in >> val; if( d < T::TValue::Dimension ) v[ d ] = val; } // rof output->Insert( v ); } // rof in.close( ); } #endif // __FPA__IO__UNIQUEVALUESCONTAINERREADER__HXX__ // eof - $RCSfile$