X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=lib%2FcpExtensions%2FAlgorithms%2FSkeletonReader.hxx;fp=lib%2FcpExtensions%2FAlgorithms%2FSkeletonReader.hxx;h=0000000000000000000000000000000000000000;hb=2e142df11d6f312a2a2b5097b8da73571ed523e8;hp=4235539f58f61f2f7ed89bcb35fa06449a3a9403;hpb=61b3659afe961ed248f30e26f9ca8f28fcfafddc;p=cpPlugins.git diff --git a/lib/cpExtensions/Algorithms/SkeletonReader.hxx b/lib/cpExtensions/Algorithms/SkeletonReader.hxx deleted file mode 100644 index 4235539..0000000 --- a/lib/cpExtensions/Algorithms/SkeletonReader.hxx +++ /dev/null @@ -1,176 +0,0 @@ -// ------------------------------------------------------------------------- -// @author Leonardo Florez-Valencia (florez-l@javeriana.edu.co) -// ------------------------------------------------------------------------- - -#ifndef __cpExtensions__Algorithms__SkeletonReader__hxx__ -#define __cpExtensions__Algorithms__SkeletonReader__hxx__ - -// ------------------------------------------------------------------------- -template< class _TSkeleton > -_TSkeleton* cpExtensions::Algorithms::SkeletonReader< _TSkeleton >:: -GetOutput( ) -{ - return( - itkDynamicCastInDebugMode< TSkeleton* >( this->GetPrimaryOutput( ) ) - ); -} - -// ------------------------------------------------------------------------- -template< class _TSkeleton > -_TSkeleton* cpExtensions::Algorithms::SkeletonReader< _TSkeleton >:: -GetOutput( unsigned int i ) -{ - return( - itkDynamicCastInDebugMode< TSkeleton* >( - this->itk::ProcessObject::GetOutput( i ) - ) - ); -} - -// ------------------------------------------------------------------------- -template< class _TSkeleton > -void cpExtensions::Algorithms::SkeletonReader< _TSkeleton >:: -GraftOutput( itk::DataObject* out ) -{ - this->GraftNthOutput( 0, out ); -} - -// ------------------------------------------------------------------------- -template< class _TSkeleton > -void cpExtensions::Algorithms::SkeletonReader< _TSkeleton >:: -GraftOutput( - const typename Superclass::DataObjectIdentifierType& key, - itk::DataObject* out - ) -{ - if( out == NULL ) - { - itkExceptionMacro( - << "Requested to graft output that is a NULL pointer" - ); - - } // fi - itk::DataObject* output = this->itk::ProcessObject::GetOutput( key ); - output->Graft( out ); -} - -// ------------------------------------------------------------------------- -template< class _TSkeleton > -void cpExtensions::Algorithms::SkeletonReader< _TSkeleton >:: -GraftNthOutput( unsigned int i, itk::DataObject* out ) -{ - if( i >= this->GetNumberOfIndexedOutputs( ) ) - { - itkExceptionMacro( - << "Requested to graft output " << i - << " but this filter only has " - << this->GetNumberOfIndexedOutputs( ) - << " indexed Outputs." - ); - - } // fi - this->GraftOutput( this->MakeNameFromOutputIndex( i ), out ); -} - -// ------------------------------------------------------------------------- -template< class _TSkeleton > -itk::DataObject::Pointer -cpExtensions::Algorithms::SkeletonReader< _TSkeleton >:: -MakeOutput( itk::ProcessObject::DataObjectPointerArraySizeType i ) -{ - return( TSkeleton::New( ).GetPointer( ) ); -} - -// ------------------------------------------------------------------------- -template< class _TSkeleton > -cpExtensions::Algorithms::SkeletonReader< _TSkeleton >:: -SkeletonReader( ) - : Superclass( ) -{ - typename TSkeleton::Pointer out = - static_cast< TSkeleton* >( this->MakeOutput( 0 ).GetPointer( ) ); - this->itk::ProcessObject::SetNumberOfRequiredInputs( 0 ); - this->itk::ProcessObject::SetNumberOfRequiredOutputs( 1 ); - this->itk::ProcessObject::SetNthOutput( 0, out.GetPointer( ) ); -} - -// ------------------------------------------------------------------------- -template< class _TSkeleton > -cpExtensions::Algorithms::SkeletonReader< _TSkeleton >:: -~SkeletonReader( ) -{ -} - -// ------------------------------------------------------------------------- -template< class _TSkeleton > -void cpExtensions::Algorithms::SkeletonReader< _TSkeleton >:: -GenerateData( ) -{ - typedef typename TSkeleton::TPath _TPath; - typedef typename _TPath::TSpacing _TSpacing; - typedef typename _TPath::TPoint _TPoint; - typedef typename _TPath::TDirection _TDirection; - typedef typename _TPath::TContinuousIndex _TContinuousIndex; - - std::string buffer; - /* TODO - if( !( cpExtensions::Read( buffer, this->m_FileName ) ) ) - { - itkExceptionMacro( - << "Error reading skeleton from \"" << this->m_FileName << "\"" - ); - return; - - } // fi - */ - - std::istringstream in( buffer ); - unsigned int dim; - in >> dim; - if( dim != TSkeleton::Dimension ) - { - itkExceptionMacro( - << "Mismatched skeletons dimension: " << dim - << " != " << TSkeleton::Dimension - ); - return; - - } // fi - - TSkeleton* out = this->GetOutput( ); - unsigned long size; - in >> size; - while( size > 0 ) - { - _TSpacing spa; - _TPoint ori; - _TDirection dir; - for( unsigned int d = 0; d < dim; ++d ) - in >> spa[ d ]; - for( unsigned int d = 0; d < dim; ++d ) - in >> ori[ d ]; - for( unsigned int d = 0; d < dim; ++d ) - for( unsigned int e = 0; e < dim; ++e ) - in >> dir[ d ][ e ]; - - typename _TPath::Pointer path = _TPath::New( ); - path->SetSpacing( spa ); - path->SetOrigin( ori ); - path->SetDirection( dir ); - for( unsigned long s = 0; s < size; ++s ) - { - _TContinuousIndex idx; - for( unsigned int d = 0; d < dim; ++d ) - in >> idx[ d ]; - path->AddVertex( idx ); - - } // rof - out->AddBranch( path ); - in >> size; - - } // elihw -} - -#endif // __cpExtensions__Algorithms__SkeletonReader__hxx__ - -// eof - $RCSfile$