X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=lib%2FcpExtensions%2FAlgorithms%2FPolyLineParametricPathWriter.hxx;fp=lib%2FcpExtensions%2FAlgorithms%2FPolyLineParametricPathWriter.hxx;h=0000000000000000000000000000000000000000;hb=2e142df11d6f312a2a2b5097b8da73571ed523e8;hp=d71c6e3aa640eb7d2d118b967883edac9ff6c4ac;hpb=61b3659afe961ed248f30e26f9ca8f28fcfafddc;p=cpPlugins.git diff --git a/lib/cpExtensions/Algorithms/PolyLineParametricPathWriter.hxx b/lib/cpExtensions/Algorithms/PolyLineParametricPathWriter.hxx deleted file mode 100644 index d71c6e3..0000000 --- a/lib/cpExtensions/Algorithms/PolyLineParametricPathWriter.hxx +++ /dev/null @@ -1,160 +0,0 @@ -// ------------------------------------------------------------------------- -// @author Leonardo Florez-Valencia (florez-l@javeriana.edu.co) -// ------------------------------------------------------------------------- - -#ifndef __cpExtensions__Algorithms__PolyLineParametricPathWriter__hxx__ -#define __cpExtensions__Algorithms__PolyLineParametricPathWriter__hxx__ - -#include - -// ------------------------------------------------------------------------- -template< class _TPolyLine, class _TImage > -void cpExtensions::Algorithms::PolyLineParametricPathWriter< _TPolyLine, _TImage >:: -SetInput( const _TPolyLine* input ) -{ - this->itk::ProcessObject::SetNthInput( - 0, const_cast< _TPolyLine* >( input ) - ); -} - -// ------------------------------------------------------------------------- -template< class _TPolyLine, class _TImage > -const _TPolyLine* -cpExtensions::Algorithms::PolyLineParametricPathWriter< _TPolyLine, _TImage >:: -GetInput( ) -{ - return( - dynamic_cast< const _TPolyLine* >( - this->itk::ProcessObject::GetInput( 0 ) - ) - ); -} - -// ------------------------------------------------------------------------- -template< class _TPolyLine, class _TImage > -void cpExtensions::Algorithms::PolyLineParametricPathWriter< _TPolyLine, _TImage >:: -SetImage( const _TImage* image ) -{ - this->itk::ProcessObject::SetNthInput( - 1, const_cast< _TImage* >( image ) - ); -} - -// ------------------------------------------------------------------------- -template< class _TPolyLine, class _TImage > -const _TImage* cpExtensions::Algorithms::PolyLineParametricPathWriter< _TPolyLine, _TImage >:: -GetImage( ) -{ - return( - dynamic_cast< const _TImage* >( - this->itk::ProcessObject::GetInput( 1 ) - ) - ); -} - -// ------------------------------------------------------------------------- -template< class _TPolyLine, class _TImage > -void cpExtensions::Algorithms::PolyLineParametricPathWriter< _TPolyLine, _TImage >:: -Update( ) -{ - _TPolyLine* input = const_cast< _TPolyLine* >( this->GetInput( ) ); - if( input != NULL ) - { - input->UpdateOutputInformation( ); - input->UpdateOutputData( ); - this->GenerateData( ); - this->ReleaseInputs( ); - - } // fi -} - -// ------------------------------------------------------------------------- -template< class _TPolyLine, class _TImage > -cpExtensions::Algorithms::PolyLineParametricPathWriter< _TPolyLine, _TImage >:: -PolyLineParametricPathWriter( ) - : Superclass( ), - m_FileName( "" ), - m_NumberOfPoints( 100 ) -{ - this->SetNumberOfRequiredInputs( 1 ); -} - -// ------------------------------------------------------------------------- -template< class _TPolyLine, class _TImage > -cpExtensions::Algorithms::PolyLineParametricPathWriter< _TPolyLine, _TImage >:: -~PolyLineParametricPathWriter( ) -{ -} - -// ------------------------------------------------------------------------- -template< class _TPolyLine, class _TImage > -void cpExtensions::Algorithms::PolyLineParametricPathWriter< _TPolyLine, _TImage >:: -GenerateData( ) -{ - typedef typename _TPolyLine::TContinuousIndex _TContinuousIndex; - - // "Serialize" data - const _TPolyLine* input = this->GetInput( ); - const _TImage* image = this->GetImage( ); - unsigned int dim = _TPolyLine::PathDimension; - std::stringstream buffer; - long step = input->GetSize( ) / this->m_NumberOfPoints; - - for( unsigned long i = 0; i < input->GetSize( ); i += step ) - { - _TContinuousIndex idx; - idx.Fill( 0 ); - int c = 0; - for( long j = -step; j <= step; ++j ) - { - long k = i + j; - if( k >= 0 && k < input->GetSize( ) ) - { - _TContinuousIndex kdx = input->GetContinuousVertex( k ); - for( unsigned int d = 0; d < dim; ++d ) - idx[ d ] += kdx[ d ]; - c++; - - } // fi - - } // rof - if( c != 0 ) - for( unsigned int d = 0; d < dim; ++d ) - idx[ d ] /= c; - - buffer << idx[ 0 ]; - for( unsigned int d = 1; d < dim; ++d ) - buffer << " " << idx[ d ]; - if( image != NULL ) - { - typename _TImage::PointType pidx; - typename _TImage::IndexType iidx; - image->TransformContinuousIndexToPhysicalPoint( idx, pidx ); - image->TransformPhysicalPointToIndex( pidx, iidx ); - buffer << " " << image->GetPixel( iidx ); - - } // fi - buffer << std::endl; - - } // rof - - // Real write - std::ofstream file_stream( - this->m_FileName.c_str( ), std::ofstream::binary - ); - if( !file_stream ) - { - itkExceptionMacro( - << "Could not open file \"" << this->m_FileName << "\" to write a " - << "cpExtensions::DataStructures::PolyLineParametricPath< " << dim - << " > object." - ); - return; - - } // fi - file_stream.write( buffer.str( ).c_str( ), buffer.str( ).size( ) ); -} - -#endif // __cpExtensions__Algorithms__PolyLineParametricPathWriter__hxx__ - -// eof - $RCSfile$