find_package(cpPlugins CONFIG REQUIRED)
## == Find eigen3 (http://eigen.tuxfamily.org)
-find_package(Eigen3 CONFIG)
+find_package(Eigen3 QUIET CONFIG)
if(Eigen3_FOUND)
include(${EIGEN3_USE_FILE})
endif(Eigen3_FOUND)
## == Installation commands
include(${cpPlugins_INSTALL_FILE})
-## == Uninstall target
-configure_file(
- "${CMAKE_CURRENT_SOURCE_DIR}/cmake_uninstall.cmake.in"
- "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
- IMMEDIATE @ONLY
- )
-add_custom_target(
- uninstall
- COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake)
-
## eof - $RCSfile$
--- /dev/null
+## =========================================================================
+## @author Leonardo Florez-Valencia (florez-l@javeriana.edu.co)
+## =========================================================================
+
+if(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt")
+ message(FATAL_ERROR "Cannot find install manifest: @CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt")
+endif(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt")
+
+file(READ "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt" files)
+string(REGEX REPLACE "\n" ";" files "${files}")
+foreach(file ${files})
+ message(STATUS "Uninstalling $ENV{DESTDIR}${file}")
+ if(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}")
+ exec_program(
+ "@CMAKE_COMMAND@" ARGS "-E remove \"$ENV{DESTDIR}${file}\""
+ OUTPUT_VARIABLE rm_out
+ RETURN_VALUE rm_retval
+ )
+ if(NOT "${rm_retval}" STREQUAL 0)
+ message(FATAL_ERROR "Problem when removing $ENV{DESTDIR}${file}")
+ endif(NOT "${rm_retval}" STREQUAL 0)
+ else(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}")
+ message(STATUS "File $ENV{DESTDIR}${file} does not exist.")
+ endif(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}")
+endforeach(file)
+
+## eof - $RCSfile$
## =========================================================================
## -- Set directories
-set(_dirs . Common DataStructures Filters Functors)
+set(_dirs . Common Filters Functors)
if(cpPlugins_USE_VTK)
list(APPEND _dirs VTK)
endif(cpPlugins_USE_VTK)
+++ /dev/null
-// =========================================================================
-// @author Leonardo Florez Valencia
-// @email florez-l@javeriana.edu.co
-// =========================================================================
-#ifndef __fpa__Common__Image__PathReader__h__
-#define __fpa__Common__Image__PathReader__h__
-
-#include <itkProcessObject.h>
-
-namespace fpa
-{
- namespace Common
- {
- namespace Image
- {
- /**
- */
- template< class _TPath >
- class PathReader
- : public itk::ProcessObject
- {
- public:
- // Basic types
- typedef PathReader Self;
- typedef itk::ProcessObject Superclass;
- typedef itk::SmartPointer< Self > Pointer;
- typedef itk::SmartPointer< const Self > ConstPointer;
-
- typedef _TPath TPath;
-
- public:
- itkNewMacro( Self );
- itkTypeMacro( PathReader, itk::ProcessObject );
-
- itkGetConstMacro( FileName, std::string );
- itkSetMacro( FileName, std::string );
-
- public:
- TPath* GetOutput( );
- TPath* GetOutput( unsigned int i );
-
- virtual void GraftOutput( itk::DataObject* out );
- virtual void GraftOutput(
- const typename Superclass::DataObjectIdentifierType& key,
- itk::DataObject* out
- );
- virtual void GraftNthOutput( unsigned int i, itk::DataObject* out );
- virtual itk::DataObject::Pointer MakeOutput(
- itk::ProcessObject::DataObjectPointerArraySizeType i
- ) override;
-
- virtual void Update( ) override
- { this->GenerateData( ); }
-
- protected:
- PathReader( );
- virtual ~PathReader( );
-
- virtual void GenerateData( ) override;
-
- // Do nothing
- virtual void GenerateOutputInformation( ) override
- { }
-
- private:
- // Purposely not implemented
- PathReader( const Self& );
- void operator=( const Self& );
-
- protected:
- std::string m_FileName;
- };
-
- } // ecapseman
-
- } // ecapseman
-
-} // ecapseman
-
-#ifndef ITK_MANUAL_INSTANTIATION
-# include <fpa/Common/Image/PathReader.hxx>
-#endif // ITK_MANUAL_INSTANTIATION
-#endif // __fpa__Common__Image__PathReader__h__
-
-// eof - $RCSfile$
+++ /dev/null
-// =========================================================================
-// @author Leonardo Florez Valencia
-// @email florez-l@javeriana.edu.co
-// =========================================================================
-#ifndef __fpa__Common__Image__PathReader__hxx__
-#define __fpa__Common__Image__PathReader__hxx__
-
-// -------------------------------------------------------------------------
-template< class _TPath >
-_TPath* fpa::Common::Image::PathReader< _TPath >::
-GetOutput( )
-{
- return(
- itkDynamicCastInDebugMode< TPath* >( this->GetPrimaryOutput( ) )
- );
-}
-
-// -------------------------------------------------------------------------
-template< class _TPath >
-_TPath* fpa::Common::Image::PathReader< _TPath >::
-GetOutput( unsigned int i )
-{
- return(
- itkDynamicCastInDebugMode< TPath* >(
- this->itk::ProcessObject::GetOutput( i )
- )
- );
-}
-
-// -------------------------------------------------------------------------
-template< class _TPath >
-void fpa::Common::Image::PathReader< _TPath >::
-GraftOutput( itk::DataObject* out )
-{
- this->GraftNthOutput( 0, out );
-}
-
-// -------------------------------------------------------------------------
-template< class _TPath >
-void fpa::Common::Image::PathReader< _TPath >::
-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 _TPath >
-void fpa::Common::Image::PathReader< _TPath >::
-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 _TPath >
-itk::DataObject::Pointer fpa::Common::Image::PathReader< _TPath >::
-MakeOutput( itk::ProcessObject::DataObjectPointerArraySizeType i )
-{
- return( TPath::New( ).GetPointer( ) );
-}
-
-// -------------------------------------------------------------------------
-template< class _TPath >
-fpa::Common::Image::PathReader< _TPath >::
-PathReader( )
- : Superclass( )
-{
- typename TPath::Pointer out =
- static_cast< TPath* >( this->MakeOutput( 0 ).GetPointer( ) );
- this->itk::ProcessObject::SetNumberOfRequiredInputs( 0 );
- this->itk::ProcessObject::SetNumberOfRequiredOutputs( 1 );
- this->itk::ProcessObject::SetNthOutput( 0, out.GetPointer( ) );
-}
-
-// -------------------------------------------------------------------------
-template< class _TPath >
-fpa::Common::Image::PathReader< _TPath >::
-~PathReader( )
-{
-}
-
-// -------------------------------------------------------------------------
-template< class _TPath >
-void fpa::Common::Image::PathReader< _TPath >::
-GenerateData( )
-{
- std::string buffer;
- std::ifstream file_stream( this->m_FileName.c_str( ) );
- if( !file_stream )
- {
- itkExceptionMacro(
- << "Error reading skeleton from \"" << this->m_FileName << "\""
- );
- return;
-
- } // fi
- file_stream.seekg( 0, std::ios::end );
- buffer.reserve( ( unsigned int )( file_stream.tellg( ) ) );
- file_stream.seekg( 0, std::ios::beg );
- buffer.assign(
- ( std::istreambuf_iterator< char >( file_stream ) ),
- std::istreambuf_iterator< char >( )
- );
- file_stream.close( );
-
- std::istringstream in( buffer );
- unsigned int dim;
- in >> dim;
- if( dim != TPath::Dimension )
- {
- itkExceptionMacro(
- << "Mismatched path dimension: " << dim
- << " != " << TPath::Dimension
- );
- return;
-
- } // fi
-
- // Read spatial parameters
- typename TPath::TSpacing spa;
- typename TPath::TDirection dir;
- typename TPath::TPoint ori;
- for( unsigned int d = 0; d < dim; ++d )
- in >> spa[ d ];
- for( unsigned int d = 0; d < dim; ++d )
- for( unsigned int e = 0; e < dim; ++e )
- in >> dir[ d ][ e ];
- for( unsigned int d = 0; d < dim; ++d )
- in >> ori[ d ];
-
- // Read path
- TPath* path = this->GetOutput( );
- path->SetSpacing( spa );
- path->SetOrigin( ori );
- path->SetDirection( dir );
-
- unsigned long pathSize;
- in >> pathSize;
- for( unsigned long id = 0; id < pathSize; ++id )
- {
- typename TPath::TIndex idx;
- for( unsigned int d = 0; d < dim; ++d )
- in >> idx[ d ];
- path->AddVertex( idx );
-
- } // rof
-}
-
-#endif // __fpa__Common__Image__PathReader__hxx__
-
-// eof - $RCSfile$
+++ /dev/null
-// =========================================================================
-// @author Leonardo Florez Valencia
-// @email florez-l@javeriana.edu.co
-// =========================================================================
-#ifndef __fpa__Common__Image__PathWriter__h__
-#define __fpa__Common__Image__PathWriter__h__
-
-#include <itkProcessObject.h>
-
-namespace fpa
-{
- namespace Common
- {
- namespace Image
- {
- /**
- */
- template< class _TPath >
- class PathWriter
- : public itk::ProcessObject
- {
- public:
- // Basic types
- typedef PathWriter Self;
- typedef itk::ProcessObject Superclass;
- typedef itk::SmartPointer< Self > Pointer;
- typedef itk::SmartPointer< const Self > ConstPointer;
-
- typedef _TPath TPath;
-
- public:
- itkNewMacro( Self );
- itkTypeMacro( PathWriter, itk::ProcessObject );
-
- itkGetConstMacro( FileName, std::string );
- itkSetMacro( FileName, std::string );
-
- public:
- const TPath* GetInput( ) const;
- void SetInput( const TPath* path );
- virtual void Update( ) override;
-
- protected:
- PathWriter( );
- virtual ~PathWriter( );
-
- virtual void GenerateData( ) override;
-
- private:
- // Purposely not implemented
- PathWriter( const Self& );
- void operator=( const Self& );
-
- protected:
- std::string m_FileName;
- };
-
- } // ecapseman
-
- } // ecapseman
-
-} // ecapseman
-
-#ifndef ITK_MANUAL_INSTANTIATION
-# include <fpa/Common/Image/PathWriter.hxx>
-#endif // ITK_MANUAL_INSTANTIATION
-#endif // __fpa__Common__Image__PathWriter__h__
-
-// eof - $RCSfile$
+++ /dev/null
-// =========================================================================
-// @author Leonardo Florez Valencia
-// @email florez-l@javeriana.edu.co
-// =========================================================================
-#ifndef __fpa__Common__Image__PathWriter__hxx__
-#define __fpa__Common__Image__PathWriter__hxx__
-
-#include <fstream>
-
-// -------------------------------------------------------------------------
-template< class _TPath >
-const _TPath* fpa::Common::Image::PathWriter< _TPath >::
-GetInput( ) const
-{
- return(
- dynamic_cast< const TPath* >(
- this->itk::ProcessObject::GetInput( 0 )
- )
- );
-}
-
-// -------------------------------------------------------------------------
-template< class _TPath >
-void fpa::Common::Image::PathWriter< _TPath >::
-SetInput( const _TPath* path )
-{
- this->itk::ProcessObject::SetNthInput( 0, const_cast< TPath* >( path ) );
-}
-
-// -------------------------------------------------------------------------
-template< class _TPath >
-void fpa::Common::Image::PathWriter< _TPath >::
-Update( )
-{
- TPath* input = const_cast< TPath* >( this->GetInput( ) );
- if( input != NULL )
- {
- input->UpdateOutputInformation( );
- input->UpdateOutputData( );
- this->GenerateData( );
- this->ReleaseInputs( );
-
- } // fi
-}
-
-// -------------------------------------------------------------------------
-template< class _TPath >
-fpa::Common::Image::PathWriter< _TPath >::
-PathWriter( )
- : Superclass( ),
- m_FileName( "" )
-{
- this->SetNumberOfRequiredInputs( 1 );
-}
-
-// -------------------------------------------------------------------------
-template< class _TPath >
-fpa::Common::Image::PathWriter< _TPath >::
-~PathWriter( )
-{
-}
-
-// -------------------------------------------------------------------------
-template< class _TPath >
-void fpa::Common::Image::PathWriter< _TPath >::
-GenerateData( )
-{
- const TPath* path = this->GetInput( );
-
- // Write base information
- std::stringstream out1, out2;
- out1 << TPath::Dimension << std::endl;
- typename TPath::TSpacing spa = path->GetSpacing( );
- for( unsigned int d = 0; d < TPath::Dimension; ++d )
- out1 << spa[ d ] << " ";
- out1 << std::endl;
- typename TPath::TDirection dir = path->GetDirection( );
- for( unsigned int d = 0; d < TPath::Dimension; ++d )
- for( unsigned int e = 0; e < TPath::Dimension; ++e )
- out1 << dir[ d ][ e ] << " ";
- out1 << std::endl;
- typename TPath::TPoint ori = path->GetOrigin( );
- for( unsigned int d = 0; d < TPath::Dimension; ++d )
- out1 << ori[ d ] << " ";
- out1 << std::endl;
-
- // Write path
- unsigned int size = path->GetSize( );
- out2 << size << std::endl;
- for( unsigned int i = 0; i < path->GetSize( ); ++i )
- {
- typename TPath::TIndex v = path->GetVertex( i );
- for( unsigned int d = 0; d < TPath::Dimension; ++d )
- out2 << v[ d ] << " ";
-
- } // rof
-
- // Real write
- std::ofstream file_stream( this->m_FileName.c_str( ), std::ofstream::binary );
- if( !file_stream )
- itkExceptionMacro(
- << "Unable to write skeleton to \""
- << this->m_FileName
- << "\""
- );
- file_stream.write( out1.str( ).c_str( ), out1.str( ).size( ) );
-}
-
-#endif // __fpa__Common__Image__PathWriter__hxx__
-
-// eof - $RCSfile$
+++ /dev/null
-// =========================================================================
-// @author Leonardo Florez Valencia
-// @email florez-l@javeriana.edu.co
-// =========================================================================
-#ifndef __fpa__Common__Image__SkeletonReader__h__
-#define __fpa__Common__Image__SkeletonReader__h__
-
-#include <itkProcessObject.h>
-
-namespace fpa
-{
- namespace Common
- {
- namespace Image
- {
- /**
- */
- template< class _TSkeleton >
- class SkeletonReader
- : public itk::ProcessObject
- {
- public:
- // Basic types
- typedef SkeletonReader Self;
- typedef itk::ProcessObject Superclass;
- typedef itk::SmartPointer< Self > Pointer;
- typedef itk::SmartPointer< const Self > ConstPointer;
-
- typedef _TSkeleton TSkeleton;
-
- public:
- itkNewMacro( Self );
- itkTypeMacro( SkeletonReader, itk::ProcessObject );
-
- itkGetConstMacro( FileName, std::string );
- itkSetMacro( FileName, std::string );
-
- public:
- TSkeleton* GetOutput( );
- TSkeleton* GetOutput( unsigned int i );
-
- virtual void GraftOutput( itk::DataObject* out );
- virtual void GraftOutput(
- const typename Superclass::DataObjectIdentifierType& key,
- itk::DataObject* out
- );
- virtual void GraftNthOutput( unsigned int i, itk::DataObject* out );
- virtual itk::DataObject::Pointer MakeOutput(
- itk::ProcessObject::DataObjectPointerArraySizeType i
- ) override;
-
- virtual void Update( ) override
- { this->GenerateData( ); }
-
- protected:
- SkeletonReader( );
- virtual ~SkeletonReader( );
-
- virtual void GenerateData( ) override;
-
- // Do nothing
- virtual void GenerateOutputInformation( ) override
- { }
-
- private:
- // Purposely not implemented
- SkeletonReader( const Self& );
- void operator=( const Self& );
-
- protected:
- std::string m_FileName;
- };
-
- } // ecapseman
-
- } // ecapseman
-
-} // ecapseman
-
-#ifndef ITK_MANUAL_INSTANTIATION
-# include <fpa/Common/Image/SkeletonReader.hxx>
-#endif // ITK_MANUAL_INSTANTIATION
-#endif // __fpa__Common__Image__SkeletonReader__h__
-
-// eof - $RCSfile$
+++ /dev/null
-// =========================================================================
-// @author Leonardo Florez Valencia
-// @email florez-l@javeriana.edu.co
-// =========================================================================
-#ifndef __fpa__Common__Image__SkeletonReader__hxx__
-#define __fpa__Common__Image__SkeletonReader__hxx__
-
-// -------------------------------------------------------------------------
-template< class _TSkeleton >
-_TSkeleton* fpa::Common::Image::SkeletonReader< _TSkeleton >::
-GetOutput( )
-{
- return(
- itkDynamicCastInDebugMode< TSkeleton* >( this->GetPrimaryOutput( ) )
- );
-}
-
-// -------------------------------------------------------------------------
-template< class _TSkeleton >
-_TSkeleton* fpa::Common::Image::SkeletonReader< _TSkeleton >::
-GetOutput( unsigned int i )
-{
- return(
- itkDynamicCastInDebugMode< TSkeleton* >(
- this->itk::ProcessObject::GetOutput( i )
- )
- );
-}
-
-// -------------------------------------------------------------------------
-template< class _TSkeleton >
-void fpa::Common::Image::SkeletonReader< _TSkeleton >::
-GraftOutput( itk::DataObject* out )
-{
- this->GraftNthOutput( 0, out );
-}
-
-// -------------------------------------------------------------------------
-template< class _TSkeleton >
-void fpa::Common::Image::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 fpa::Common::Image::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
-fpa::Common::Image::SkeletonReader< _TSkeleton >::
-MakeOutput( itk::ProcessObject::DataObjectPointerArraySizeType i )
-{
- return( TSkeleton::New( ).GetPointer( ) );
-}
-
-// -------------------------------------------------------------------------
-template< class _TSkeleton >
-fpa::Common::Image::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 >
-fpa::Common::Image::SkeletonReader< _TSkeleton >::
-~SkeletonReader( )
-{
-}
-
-// -------------------------------------------------------------------------
-template< class _TSkeleton >
-void fpa::Common::Image::SkeletonReader< _TSkeleton >::
-GenerateData( )
-{
- typedef typename TSkeleton::TPath _TPath;
- typedef typename _TPath::TIndex _TIndex;
- typedef typename _TPath::TSpacing _TSpacing;
- typedef typename _TPath::TPoint _TPoint;
- typedef typename _TPath::TDirection _TDirection;
-
- std::string buffer;
- std::ifstream file_stream( this->m_FileName.c_str( ) );
- if( !file_stream )
- {
- itkExceptionMacro(
- << "Error reading skeleton from \"" << this->m_FileName << "\""
- );
- return;
-
- } // fi
- file_stream.seekg( 0, std::ios::end );
- buffer.reserve( ( unsigned int )( file_stream.tellg( ) ) );
- file_stream.seekg( 0, std::ios::beg );
- buffer.assign(
- ( std::istreambuf_iterator< char >( file_stream ) ),
- std::istreambuf_iterator< char >( )
- );
- file_stream.close( );
-
- std::istringstream in( buffer );
- unsigned int dim;
- in >> dim;
- if( dim != TSkeleton::Dimension )
- {
- itkExceptionMacro(
- << "Mismatched skeletons dimension: " << dim
- << " != " << TSkeleton::Dimension
- );
- return;
-
- } // fi
-
- // Read spatial parameters
- _TSpacing spa;
- _TDirection dir;
- _TPoint ori;
- for( unsigned int d = 0; d < dim; ++d )
- in >> spa[ d ];
- for( unsigned int d = 0; d < dim; ++d )
- for( unsigned int e = 0; e < dim; ++e )
- in >> dir[ d ][ e ];
- for( unsigned int d = 0; d < dim; ++d )
- in >> ori[ d ];
-
- // Read end-points, just to ignore
- unsigned int n;
- in >> n;
- for( unsigned int i = 0; i < n; ++i )
- {
- _TIndex idx;
- for( unsigned int d = 0; d < dim; ++d )
- in >> idx[ d ];
-
- } // rof
-
- // Read bifurcations, just to ignore
- in >> n;
- for( unsigned int i = 0; i < n; ++i )
- {
- _TIndex idx;
- for( unsigned int d = 0; d < dim; ++d )
- in >> idx[ d ];
-
- } // rof
-
- // Read paths
- TSkeleton* out = this->GetOutput( );
- unsigned int nPaths;
- in >> nPaths;
- for( unsigned int p = 0; p < nPaths; ++p )
- {
- typename _TPath::Pointer path = _TPath::New( );
- path->SetSpacing( spa );
- path->SetOrigin( ori );
- path->SetDirection( dir );
-
- unsigned long pathSize;
- in >> pathSize;
- for( unsigned long id = 0; id < pathSize; ++id )
- {
- _TIndex idx;
- for( unsigned int d = 0; d < dim; ++d )
- in >> idx[ d ];
- path->AddVertex( idx );
-
- } // rof
- out->AddBranch( path );
-
- } // rof
-}
-
-#endif // __fpa__Common__Image__SkeletonReader__hxx__
-
-// eof - $RCSfile$
+++ /dev/null
-// =========================================================================
-// @author Leonardo Florez Valencia
-// @email florez-l@javeriana.edu.co
-// =========================================================================
-#ifndef __fpa__Common__Image__SkeletonWriter__h__
-#define __fpa__Common__Image__SkeletonWriter__h__
-
-#include <itkProcessObject.h>
-
-namespace fpa
-{
- namespace Common
- {
- namespace Image
- {
- /**
- */
- template< class _TSkeleton >
- class SkeletonWriter
- : public itk::ProcessObject
- {
- public:
- // Basic types
- typedef SkeletonWriter Self;
- typedef itk::ProcessObject Superclass;
- typedef itk::SmartPointer< Self > Pointer;
- typedef itk::SmartPointer< const Self > ConstPointer;
-
- typedef _TSkeleton TSkeleton;
- typedef typename TSkeleton::TEdges TEdges;
- typedef typename TSkeleton::TMatrix TMatrix;
- typedef typename TSkeleton::TMatrixRow TMatrixRow;
- typedef typename TSkeleton::TPath TPath;
- typedef typename TSkeleton::TVertex TVertex;
-
- public:
- itkNewMacro( Self );
- itkTypeMacro( SkeletonWriter, itk::ProcessObject );
-
- itkGetConstMacro( FileName, std::string );
- itkSetMacro( FileName, std::string );
-
- public:
- const TSkeleton* GetInput( ) const;
- void SetInput( const TSkeleton* skeleton );
- virtual void Update( ) override;
-
- protected:
- SkeletonWriter( );
- virtual ~SkeletonWriter( );
-
- virtual void GenerateData( ) override;
-
- private:
- // Purposely not implemented
- SkeletonWriter( const Self& );
- void operator=( const Self& );
-
- protected:
- std::string m_FileName;
- };
-
- } // ecapseman
-
- } // ecapseman
-
-} // ecapseman
-
-#ifndef ITK_MANUAL_INSTANTIATION
-# include <fpa/Common/Image/SkeletonWriter.hxx>
-#endif // ITK_MANUAL_INSTANTIATION
-#endif // __fpa__Common__Image__SkeletonWriter__h__
-
-// eof - $RCSfile$
+++ /dev/null
-// =========================================================================
-// @author Leonardo Florez Valencia
-// @email florez-l@javeriana.edu.co
-// =========================================================================
-#ifndef __fpa__Common__Image__SkeletonWriter__hxx__
-#define __fpa__Common__Image__SkeletonWriter__hxx__
-
-#include <fstream>
-
-// -------------------------------------------------------------------------
-template< class _TSkeleton >
-const _TSkeleton* fpa::Common::Image::SkeletonWriter< _TSkeleton >::
-GetInput( ) const
-{
- return(
- dynamic_cast< const TSkeleton* >(
- this->itk::ProcessObject::GetInput( 0 )
- )
- );
-}
-
-// -------------------------------------------------------------------------
-template< class _TSkeleton >
-void fpa::Common::Image::SkeletonWriter< _TSkeleton >::
-SetInput( const _TSkeleton* skeleton )
-{
- this->itk::ProcessObject::SetNthInput(
- 0, const_cast< TSkeleton* >( skeleton )
- );
-}
-
-// -------------------------------------------------------------------------
-template< class _TSkeleton >
-void fpa::Common::Image::SkeletonWriter< _TSkeleton >::
-Update( )
-{
- TSkeleton* input = const_cast< TSkeleton* >( this->GetInput( ) );
- if( input != NULL )
- {
- input->UpdateOutputInformation( );
- input->UpdateOutputData( );
- this->GenerateData( );
- this->ReleaseInputs( );
-
- } // fi
-}
-
-// -------------------------------------------------------------------------
-template< class _TSkeleton >
-fpa::Common::Image::SkeletonWriter< _TSkeleton >::
-SkeletonWriter( )
- : Superclass( ),
- m_FileName( "" )
-{
- this->SetNumberOfRequiredInputs( 1 );
-}
-
-// -------------------------------------------------------------------------
-template< class _TSkeleton >
-fpa::Common::Image::SkeletonWriter< _TSkeleton >::
-~SkeletonWriter( )
-{
-}
-
-// -------------------------------------------------------------------------
-template< class _TSkeleton >
-void fpa::Common::Image::SkeletonWriter< _TSkeleton >::
-GenerateData( )
-{
- const TSkeleton* sk = this->GetInput( );
- typename TMatrix::const_iterator mIt = sk->BeginEdgesRows( );
- typename TMatrixRow::const_iterator rIt = mIt->second.begin( );
- typename TEdges::const_iterator eIt = rIt->second.begin( );
- const TPath* path = *eIt;
-
- // Write base information
- std::stringstream out1, out2;
- out1 << TSkeleton::Dimension << std::endl;
- typename TPath::TSpacing spa = path->GetSpacing( );
- for( unsigned int d = 0; d < TSkeleton::Dimension; ++d )
- out1 << spa[ d ] << " ";
- out1 << std::endl;
- typename TPath::TDirection dir = path->GetDirection( );
- for( unsigned int d = 0; d < TSkeleton::Dimension; ++d )
- for( unsigned int e = 0; e < TSkeleton::Dimension; ++e )
- out1 << dir[ d ][ e ] << " ";
- out1 << std::endl;
- typename TPath::TPoint ori = path->GetOrigin( );
- for( unsigned int d = 0; d < TSkeleton::Dimension; ++d )
- out1 << ori[ d ] << " ";
- out1 << std::endl;
-
- // End points
- std::vector< TVertex > end_points = sk->GetEndPoints( );
- out1 << end_points.size( ) << std::endl;
- typename std::vector< TVertex >::const_iterator epIt = end_points.begin( );
- for( ; epIt != end_points.end( ); ++epIt )
- {
- for( unsigned int d = 0; d < TSkeleton::Dimension; ++d )
- out1 << ( *epIt )[ d ] << " ";
- out1 << std::endl;
-
- } // rof
-
- // Bifurcations
- std::vector< TVertex > bifurcations = sk->GetBifurcations( );
- out1 << bifurcations.size( ) << std::endl;
- typename std::vector< TVertex >::const_iterator bIt = bifurcations.begin( );
- for( ; bIt != bifurcations.end( ); ++bIt )
- {
- for( unsigned int d = 0; d < TSkeleton::Dimension; ++d )
- out1 << ( *bIt )[ d ] << " ";
- out1 << std::endl;
-
- } // rof
-
- // Write paths
- unsigned long pathCount = 0;
- mIt = sk->BeginEdgesRows( );
- for( ; mIt != sk->EndEdgesRows( ); ++mIt )
- {
- typename TMatrixRow::const_iterator rIt = mIt->second.begin( );
- for( ; rIt != mIt->second.end( ); ++rIt )
- {
- typename TEdges::const_iterator eIt = rIt->second.begin( );
- for( ; eIt != rIt->second.end( ); ++eIt )
- {
- TPath* path = *eIt;
- pathCount++;
- unsigned int size = path->GetSize( );
- out2 << size << std::endl;
- for( unsigned int i = 0; i < path->GetSize( ); ++i )
- {
- TVertex v = path->GetVertex( i );
- for( unsigned int d = 0; d < TSkeleton::Dimension; ++d )
- out2 << v[ d ] << " ";
-
- } // rof
- out2 << std::endl;
-
- } // rof
-
- } // rof
-
- } // rof
- out1 << pathCount << std::endl << out2.str( );
-
- // Real write
- std::ofstream file_stream( this->m_FileName.c_str( ), std::ofstream::binary );
- if( !file_stream )
- itkExceptionMacro(
- << "Unable to write skeleton to \""
- << this->m_FileName
- << "\""
- );
- file_stream.write( out1.str( ).c_str( ), out1.str( ).size( ) );
-}
-
-#endif // __fpa__Common__Image__SkeletonWriter__hxx__
-
-// eof - $RCSfile$
// @author Leonardo Florez Valencia
// @email florez-l@javeriana.edu.co
// =========================================================================
-#ifndef __fpa__Common__OriginalRandomWalker__h__
-#define __fpa__Common__OriginalRandomWalker__h__
+#ifndef __fpa__Common__RandomWalker__h__
+#define __fpa__Common__RandomWalker__h__
#include <fpa/Config.h>
#include <map>
/**
*/
template< class _TImage, class _TLabels, class _TScalar = float >
- class OriginalRandomWalker
+ class RandomWalker
: public itk::ImageToImageFilter< _TImage, _TLabels >
{
public:
typedef _TLabels TLabels;
typedef _TScalar TScalar;
- typedef OriginalRandomWalker Self;
+ typedef RandomWalker Self;
typedef itk::ImageToImageFilter< TImage, TLabels > Superclass;
typedef itk::SmartPointer< Self > Pointer;
typedef itk::SmartPointer< const Self > ConstPointer;
public:
itkNewMacro( Self );
itkTypeMacro(
- fpa::Common::OriginalRandomWalker, itk::ImageToImageFilter
+ fpa::Common::RandomWalker, itk::ImageToImageFilter
);
itkGetConstObjectMacro( EdgeFunction, TEdgeFunction );
fpaFilterInputMacro( InputLabels, TLabels );
fpaFilterOutputMacro( OutputProbabilities, TScalarImage );
- /* TODO
- public:
- void AddSeed( const TIndex& seed, const TLabel& label );
- */
-
protected:
- OriginalRandomWalker( );
- virtual ~OriginalRandomWalker( );
+ RandomWalker( );
+ virtual ~RandomWalker( );
virtual void GenerateData( ) override;
private:
// Purposely not implemented
- OriginalRandomWalker( const Self& other );
+ RandomWalker( const Self& other );
Self& operator=( const Self& other );
protected:
- /* TODO
- std::vector< TIndex > m_Seeds;
- std::vector< TLabel > m_Labels;
- */
-
typename TEdgeFunction::Pointer m_EdgeFunction;
-
itk::SimpleFastMutexLock m_Mutex;
};
} // ecapseman
#ifndef ITK_MANUAL_INSTANTIATION
-# include <fpa/Common/OriginalRandomWalker.hxx>
+# include <fpa/Common/RandomWalker.hxx>
#endif // ITK_MANUAL_INSTANTIATION
-#endif // __fpa__Common__OriginalRandomWalker__h__
+#endif // __fpa__Common__RandomWalker__h__
// eof - $RCSfile$
// @author Leonardo Florez Valencia
// @email florez-l@javeriana.edu.co
// =========================================================================
-#ifndef __fpa__Common__OriginalRandomWalker__hxx__
-#define __fpa__Common__OriginalRandomWalker__hxx__
+#ifndef __fpa__Common__RandomWalker__hxx__
+#define __fpa__Common__RandomWalker__hxx__
#include <itkImageRegionConstIteratorWithIndex.h>
#include <itkImageRegionIteratorWithIndex.h>
-#include <Eigen/Sparse>
-
-// -------------------------------------------------------------------------
-/* TODO
- template< class _TImage, class _TLabels, class _TScalar >
- void fpa::Common::OriginalRandomWalker< _TImage, _TLabels, _TScalar >::
- AddSeed( const TIndex& seed, const TLabel& label )
- {
- this->m_Seeds.push_back( seed );
- this->m_Labels.push_back( label );
- this->Modified( );
- }
-*/
+#ifdef USE_Eigen3
+# include <Eigen/Sparse>
+#endif // USE_Eigen3
// -------------------------------------------------------------------------
template< class _TImage, class _TLabels, class _TScalar >
-fpa::Common::OriginalRandomWalker< _TImage, _TLabels, _TScalar >::
-OriginalRandomWalker( )
+fpa::Common::RandomWalker< _TImage, _TLabels, _TScalar >::
+RandomWalker( )
: Superclass( )
{
fpaFilterInputConfigureMacro( InputLabels, TLabels );
// -------------------------------------------------------------------------
template< class _TImage, class _TLabels, class _TScalar >
-fpa::Common::OriginalRandomWalker< _TImage, _TLabels, _TScalar >::
-~OriginalRandomWalker( )
+fpa::Common::RandomWalker< _TImage, _TLabels, _TScalar >::
+~RandomWalker( )
{
}
// -------------------------------------------------------------------------
template< class _TImage, class _TLabels, class _TScalar >
-void fpa::Common::OriginalRandomWalker< _TImage, _TLabels, _TScalar >::
+void fpa::Common::RandomWalker< _TImage, _TLabels, _TScalar >::
GenerateData( )
{
+#ifdef USE_Eigen3
// Useful typedefs
typedef Eigen::Triplet< TScalar > _TTriplet;
typedef std::vector< _TTriplet > _TTriplets;
// Fill outputs
itkDebugMacro( << "Filling output..." );
this->_Output( x, St, invLabels );
+#endif // USE_Eigen3
}
// -------------------------------------------------------------------------
template< class _TImage, class _TLabels, class _TScalar >
-_TScalar fpa::Common::OriginalRandomWalker< _TImage, _TLabels, _TScalar >::
+_TScalar fpa::Common::RandomWalker< _TImage, _TLabels, _TScalar >::
_L( const TIndex& i, const TIndex& j )
{
+#ifdef USE_Eigen3
if( i == j )
{
TRegion r = this->GetInput( )->GetRequestedRegion( );
}
else
return( -( this->m_EdgeFunction->Evaluate( i, j ) ) );
+#else // USE_Eigen3
+ return( _TScalar( 0 ) );
+#endif // USE_Eigen3
}
// -------------------------------------------------------------------------
template< class _TImage, class _TLabels, class _TScalar >
template< class _TTriplets >
-void fpa::Common::OriginalRandomWalker< _TImage, _TLabels, _TScalar >::
+void fpa::Common::RandomWalker< _TImage, _TLabels, _TScalar >::
_Boundary( _TTriplets& B, std::map< TLabel, unsigned long >& labels )
{
+#ifdef USE_Eigen3
B.clear( );
// Set up the multithreaded processing
// Execute threader
threads->SingleMethodExecute( );
+#endif // USE_Eigen3
}
// -------------------------------------------------------------------------
template< class _TImage, class _TLabels, class _TScalar >
template< class _TTriplets >
ITK_THREAD_RETURN_TYPE
-fpa::Common::OriginalRandomWalker< _TImage, _TLabels, _TScalar >::
+fpa::Common::RandomWalker< _TImage, _TLabels, _TScalar >::
_BoundaryCbk( void* arg )
{
+#ifdef USE_Eigen3
_TBoundaryThreadStruct* thrStr;
itk::ThreadIdType total, thrId, thrCount;
itk::MultiThreader::ThreadInfoStruct* thrInfo =
reinterpret_cast< _TTriplets* >( thrStr->Triplets ),
thrStr->Labels
);
+#endif // USE_Eigen3
return( ITK_THREAD_RETURN_VALUE );
}
// -------------------------------------------------------------------------
template< class _TImage, class _TLabels, class _TScalar >
template< class _TTriplets >
-void fpa::Common::OriginalRandomWalker< _TImage, _TLabels, _TScalar >::
+void fpa::Common::RandomWalker< _TImage, _TLabels, _TScalar >::
_ThreadedBoundary(
const TRegion& region, const itk::ThreadIdType& id,
_TTriplets* B,
std::map< TLabel, unsigned long >* labels
)
{
+#ifdef USE_Eigen3
typedef itk::ImageRegionConstIteratorWithIndex< TLabels > _TIt;
typedef typename std::map< TLabel, unsigned long >::value_type _TMapValue;
typedef typename std::map< unsigned long, TLabel >::value_type _TInvValue;
} // fi
} // rof
+#endif // USE_Eigen3
}
// -------------------------------------------------------------------------
template< class _TImage, class _TLabels, class _TScalar >
template< class _TTriplets >
-void fpa::Common::OriginalRandomWalker< _TImage, _TLabels, _TScalar >::
+void fpa::Common::RandomWalker< _TImage, _TLabels, _TScalar >::
_Laplacian( _TTriplets& A, _TTriplets& R, const _TTriplets& B )
{
+#ifdef USE_Eigen3
A.clear( );
R.clear( );
// Execute threader
threads->SingleMethodExecute( );
+#endif // USE_Eigen3
}
// -------------------------------------------------------------------------
template< class _TImage, class _TLabels, class _TScalar >
template< class _TTriplets >
ITK_THREAD_RETURN_TYPE
-fpa::Common::OriginalRandomWalker< _TImage, _TLabels, _TScalar >::
+fpa::Common::RandomWalker< _TImage, _TLabels, _TScalar >::
_LaplacianCbk( void* arg )
{
+#ifdef USE_Eigen3
_TLaplacianThreadStruct* thrStr;
itk::ThreadIdType total, thrId, thrCount;
itk::MultiThreader::ThreadInfoStruct* thrInfo =
reinterpret_cast< _TTriplets* >( thrStr->R ),
reinterpret_cast< const _TTriplets* >( thrStr->B )
);
+#endif // USE_Eigen3
return( ITK_THREAD_RETURN_VALUE );
}
// -------------------------------------------------------------------------
template< class _TImage, class _TLabels, class _TScalar >
template< class _TTriplets >
-void fpa::Common::OriginalRandomWalker< _TImage, _TLabels, _TScalar >::
+void fpa::Common::RandomWalker< _TImage, _TLabels, _TScalar >::
_ThreadedLaplacian(
const TRegion& region, const itk::ThreadIdType& id,
_TTriplets* A, _TTriplets* R, const _TTriplets* B
)
{
+#ifdef USE_Eigen3
typedef itk::ImageRegionConstIteratorWithIndex< TImage > _TIt;
typedef typename _TTriplets::value_type _TTriplet;
} // rof
} // rof
+#endif // USE_Eigen3
}
// -------------------------------------------------------------------------
template< class _TImage, class _TLabels, class _TScalar >
template< class _TMatrix, class _TTriplets >
-void fpa::Common::OriginalRandomWalker< _TImage, _TLabels, _TScalar >::
+void fpa::Common::RandomWalker< _TImage, _TLabels, _TScalar >::
_Output(
const _TMatrix& X, const _TTriplets& S, const std::vector< TLabel >& invLabels
)
{
+#ifdef USE_Eigen3
// Set up the multithreaded processing
_TOutputThreadStruct thrStr;
thrStr.Filter = this;
// Execute threader
threads->SingleMethodExecute( );
+#endif // USE_Eigen3
}
// -------------------------------------------------------------------------
template< class _TImage, class _TLabels, class _TScalar >
template< class _TMatrix, class _TTriplets >
ITK_THREAD_RETURN_TYPE
-fpa::Common::OriginalRandomWalker< _TImage, _TLabels, _TScalar >::
+fpa::Common::RandomWalker< _TImage, _TLabels, _TScalar >::
_OutputCbk( void* arg )
{
+#ifdef USE_Eigen3
_TOutputThreadStruct* thrStr;
itk::ThreadIdType total, thrId, thrCount;
itk::MultiThreader::ThreadInfoStruct* thrInfo =
reinterpret_cast< const _TTriplets* >( thrStr->S ),
thrStr->InvLabels
);
+#endif // USE_Eigen3
return( ITK_THREAD_RETURN_VALUE );
}
// -------------------------------------------------------------------------
template< class _TImage, class _TLabels, class _TScalar >
template< class _TMatrix, class _TTriplets >
-void fpa::Common::OriginalRandomWalker< _TImage, _TLabels, _TScalar >::
+void fpa::Common::RandomWalker< _TImage, _TLabels, _TScalar >::
_ThreadedOutput(
const TRegion& region, const itk::ThreadIdType& id,
const _TMatrix* X, const _TTriplets* S,
const std::vector< TLabel >* invLabels
)
{
+#ifdef USE_Eigen3
// Fill outputs
const TLabels* in_labels = this->GetInputLabels( );
TLabels* out_labels = this->GetOutput( );
} // fi
} // rof
+#endif // USE_Eigen3
}
// -------------------------------------------------------------------------
template< class _TImage, class _TLabels, class _TScalar >
unsigned long
-fpa::Common::OriginalRandomWalker< _TImage, _TLabels, _TScalar >::
+fpa::Common::RandomWalker< _TImage, _TLabels, _TScalar >::
_1D( const TIndex& idx, const TRegion& region )
{
unsigned long i = idx[ 0 ];
template< class _TImage, class _TLabels, class _TScalar >
template< class _TTriplets >
unsigned long
-fpa::Common::OriginalRandomWalker< _TImage, _TLabels, _TScalar >::
+fpa::Common::RandomWalker< _TImage, _TLabels, _TScalar >::
_SeedIndex( const unsigned long& i, const _TTriplets& t )
{
unsigned long s = 0;
template< class _TImage, class _TLabels, class _TScalar >
template< class _TTriplets >
unsigned long
-fpa::Common::OriginalRandomWalker< _TImage, _TLabels, _TScalar >::
+fpa::Common::RandomWalker< _TImage, _TLabels, _TScalar >::
_NearSeedIndex( const unsigned long& i, const _TTriplets& t )
{
long s = 0;
return( i - d );
}
-#endif // __fpa__Common__OriginalRandomWalker__hxx__
+#endif // __fpa__Common__RandomWalker__hxx__
+
// eof - $RCSfile$
#ifndef __fpa__Config__h__
#define __fpa__Config__h__
+#include <ivq/Config.h>
#include <fpa/fpa_export.h>
-#include <itkMacro.h>
#if @Eigen3_FOUND@ == 1
# define USE_Eigen3
typedef __t__::TInternalTraits::TSeeds TSeeds; \
typedef __t__::TInternalTraits::TVertex TVertex
-// -------------------------------------------------------------------------
-#define fpaFilterInputMacro( __n__, __t__ ) \
- private: \
- unsigned int m_##__n__##Idx; \
- public: \
- __t__* Get##__n__( ) \
- { \
- return( \
- dynamic_cast< __t__* >( \
- this->itk::ProcessObject::GetInput( \
- this->m_##__n__##Idx \
- ) ) ); \
- } \
- const __t__* Get##__n__( ) const \
- { \
- return( \
- dynamic_cast< const __t__* >( \
- this->itk::ProcessObject::GetInput( \
- this->m_##__n__##Idx \
- ) ) ); \
- } \
- void Set##__n__( const __t__* i ) \
- { \
- this->itk::ProcessObject::SetNthInput( \
- this->m_##__n__##Idx, \
- const_cast< __t__* >( i ) \
- ); \
- }
-
-// -------------------------------------------------------------------------
-#define fpaFilterInputConfigureMacro( __n__, __t__ ) \
- this->m_##__n__##Idx = this->GetNumberOfRequiredInputs( ); \
- this->itk::ProcessObject::SetNumberOfRequiredInputs( \
- this->m_##__n__##Idx + 1 \
- )
-
-// -------------------------------------------------------------------------
-#define fpaFilterOutputMacro( __n__, __t__ ) \
- private: \
- unsigned int m_##__n__##Idx; \
- public: \
- __t__* Get##__n__( ) \
- { \
- return( \
- dynamic_cast< __t__* >( \
- this->itk::ProcessObject::GetOutput( \
- this->m_##__n__##Idx \
- ) ) ); \
- } \
- const __t__* Get##__n__( ) const \
- { \
- return( \
- dynamic_cast< const __t__* >( \
- this->itk::ProcessObject::GetOutput( \
- this->m_##__n__##Idx \
- ) ) ); \
- }
-
-// -------------------------------------------------------------------------
-#define fpaFilterOutputConfigureMacro( __n__, __t__ ) \
- this->m_##__n__##Idx = this->GetNumberOfRequiredOutputs( ); \
- this->itk::ProcessObject::SetNumberOfRequiredOutputs( \
- this->m_##__n__##Idx + 1 \
- ); \
- this->SetNthOutput( this->m_##__n__##Idx, __t__::New( ) )
-
#endif // __fpa__Config__h__
// eof - $RCSfile$
+++ /dev/null
-// =========================================================================
-// @author Leonardo Florez Valencia
-// @email florez-l@javeriana.edu.co
-// =========================================================================
-#ifndef __fpa__DataStructures__Graph__h__
-#define __fpa__DataStructures__Graph__h__
-
-#include <map>
-#include <set>
-#include <vector>
-#include <itkDataObject.h>
-#include <itkObjectFactory.h>
-
-namespace fpa
-{
- namespace DataStructures
- {
- /** \brief A generic graph with templated index types.
- *
- * @param _TVertex Vertex type.
- * @param _TCost Cost type.
- * @param _TIndex Index type (it should be a strict weak ordering type).
- */
- template< class _TVertex, class _TCost, class _TIndex = unsigned long, class _TIndexCompare = std::less< _TIndex > >
- class Graph
- : public itk::DataObject
- {
- public:
- typedef Graph Self;
- typedef itk::DataObject Superclass;
- typedef itk::SmartPointer< Self > Pointer;
- typedef itk::SmartPointer< const Self > ConstPointer;
-
- typedef _TVertex TVertex;
- typedef _TCost TCost;
- typedef _TIndex TIndex;
- typedef _TIndexCompare TIndexCompare;
-
- // Base types
- typedef std::map< TIndex, TVertex, TIndexCompare > TVertices;
- typedef std::vector< TCost > TEdges;
- typedef std::map< TIndex, TEdges, TIndexCompare > TMatrixRow;
- typedef std::map< TIndex, TMatrixRow, TIndexCompare > TMatrix;
-
- public:
- itkNewMacro( Self );
- itkTypeMacro( Graph, itk::DataObject );
-
- public:
- /*! \brief Iterators over vertices.
- * These allow you to iterate over all of graph's vertices.
- *
- * Typical iteration should be done as:
- *
- * TGraph g;
- * ...
- * TGraph::TVertices::[const_]iterator vIt = g.BeginVertices( );
- * for( ; vIt != g.EndVertices( ); ++vIt )
- * {
- * vIt->first; --> this is the vertex's index <--
- * vIt->second; --> this is the vertex's value <--
- * }
- */
- inline typename TVertices::iterator BeginVertices( )
- { return( this->m_Vertices.begin( ) ); }
- inline typename TVertices::iterator EndVertices( )
- { return( this->m_Vertices.end( ) ); }
- inline typename TVertices::const_iterator BeginVertices( ) const
- { return( this->m_Vertices.begin( ) ); }
- inline typename TVertices::const_iterator EndVertices( ) const
- { return( this->m_Vertices.end( ) ); }
-
- /*! \brief Iterators over edges.
- * These allow you to iterate over all of graph's edges.
- *
- * Typical iteration should be done as:
- *
- * TGraph g;
- * ...
- * TGraph::TMatrix::[const_]iterator mIt = g.BeginEdgesRows( );
- * for( ; mIt != g.EndEdgesRows( ); ++mIt )
- * {
- * mIt->first; --> this is the row index. <--
- * TGraph::TMatrixRow::[const_]iterator rIt = mIt->second.begin( );
- * for( ; rIt != mIt->second.end( ); ++rIt )
- * {
- * rIt->first; --> this is the column index.
- * TGraph::TEdges::[const_]iterator eIt = rIt->second.begin( );
- * for( ; eIt != rIt->second.end( ); ++eIt )
- * *eIt; --> this is the cost between mIt->first and rIt->first
- * }
- * }
- */
- inline typename TMatrix::iterator BeginEdgesRows( )
- { return( this->m_Matrix.begin( ) ); }
- inline typename TMatrix::iterator EndEdgetsRows( )
- { return( this->m_Matrix.end( ) ); }
- inline typename TMatrix::const_iterator BeginEdgesRows( ) const
- { return( this->m_Matrix.begin( ) ); }
- inline typename TMatrix::const_iterator EndEdgesRows( ) const
- { return( this->m_Matrix.end( ) ); }
-
- /*! \brief Clear all vertices and edges.
- */
- void Clear( );
-
- /*! \brief Clear all edges.
- */
- inline void ClearEdges( )
- { this->m_Matrix.clear( ); }
-
- /*! \brief Vertex manipulation methods.
- * Names are self-explanatory.
- */
- inline bool HasVertexIndex( const TIndex& i ) const
- { return( this->m_Vertices.find( i ) != this->m_Vertices.end( ) ); }
- inline void SetVertex( const TIndex& index, TVertex& vertex )
- { this->m_Vertices[ index ] = vertex; }
- inline TVertex& GetVertex( const TIndex& index )
- { return( this->m_Vertices[ index ] ); }
- inline const TVertex& GetVertex( const TIndex& index ) const
- { return( this->m_Vertices[ index ] ); }
- bool RenameVertex( const TIndex& old_index, const TIndex& new_index );
- void RemoveVertex( const TIndex& index );
-
- /*! \brief Edge manipulation methods.
- * Names are self-explanatory.
- */
- inline void AddEdge( const TIndex& orig, const TIndex& dest, const TCost& cost )
- { this->m_Matrix[ orig ][ dest ].push_back( cost ); }
- TEdges& GetEdges( const TIndex& orig, const TIndex& dest );
- const TEdges& GetEdges( const TIndex& orig, const TIndex& dest ) const;
- bool HasEdge( const TIndex& orig, const TIndex& dest ) const;
- void RemoveEdge( const TIndex& orig, const TIndex& dest, const TCost& cost );
- void RemoveEdges( const TIndex& orig, const TIndex& dest );
-
- /*! \brief Returns graph's sinks.
- *
- * A sink is a special vertex which does not have any "exiting" edges.
- *
- * @return Sinks ordered by their index.
- */
- std::set< TIndex, TIndexCompare > GetSinks( ) const;
-
- protected:
- Graph( );
- virtual ~Graph( );
-
- private:
- // Purposely not implemented
- Graph( const Self& other );
- Self& operator=( const Self& other );
-
- protected:
- TVertices m_Vertices;
- TMatrix m_Matrix;
- };
-
- } // ecapseman
-
-} // ecapseman
-
-#ifndef ITK_MANUAL_INSTANTIATION
-# include <fpa/DataStructures/Graph.hxx>
-#endif // ITK_MANUAL_INSTANTIATION
-#endif // __fpa__DataStructures__Graph__h__
-// eof - $RCSfile$
+++ /dev/null
-// =========================================================================
-// @author Leonardo Florez Valencia
-// @email florez-l@javeriana.edu.co
-// =========================================================================
-#ifndef __fpa__DataStructures__Graph__hxx__
-#define __fpa__DataStructures__Graph__hxx__
-
-// -------------------------------------------------------------------------
-template< class _TVertex, class _TCost, class _TIndex, class _TIndexCompare >
-void fpa::DataStructures::Graph< _TVertex, _TCost, _TIndex, _TIndexCompare >::
-Clear( )
-{
- this->m_Vertices.clear( );
- this->m_Matrix.clear( );
-}
-
-// -------------------------------------------------------------------------
-template< class _TVertex, class _TCost, class _TIndex, class _TIndexCompare >
-bool fpa::DataStructures::Graph< _TVertex, _TCost, _TIndex, _TIndexCompare >::
-RenameVertex( const TIndex& old_index, const TIndex& new_index )
-{
- typename TVertices::iterator old_v = this->m_Vertices.find( old_index );
- typename TVertices::iterator new_v = this->m_Vertices.find( new_index );
- if( old_v != this->m_Vertices.end( ) && new_v == this->m_Vertices.end( ) )
- {
- // Replace vertex
- this->m_Vertices[ new_index ] = old_v->second;
- this->m_Vertices.erase( old_index );
-
- // Duplicate edges
- typename TMatrix::iterator mIt = this->m_Matrix.begin( );
- typename TMatrix::iterator found_row = this->m_Matrix.end( );
- for( ; mIt != this->m_Matrix.end( ); ++mIt )
- {
- if( mIt->first == old_index )
- found_row = mIt;
-
- typename TMatrixRow::iterator rIt = mIt->second.begin( );
- for( ; rIt != mIt->second.end( ); ++rIt )
- {
- if( mIt->first == old_index )
- this->m_Matrix[ new_index ][ rIt->first ] = rIt->second;
- else if( rIt->first == old_index )
- this->m_Matrix[ mIt->first ][ new_index ] = rIt->second;
-
- } // rof
-
- } // rof
-
- // Delete old edges
- if( found_row != this->m_Matrix.end( ) )
- this->m_Matrix.erase( found_row );
-
- mIt = this->m_Matrix.begin( );
- for( ; mIt != this->m_Matrix.end( ); ++mIt )
- {
- typename TMatrixRow::iterator rIt = mIt->second.begin( );
- while( rIt != mIt->second.end( ) )
- {
- if( rIt->first == old_index )
- {
- mIt->second.erase( rIt );
- rIt = mIt->second.begin( );
- }
- else
- ++rIt;
-
- } // elihw
-
- } // rof
- return( true );
- }
- else
- return( false );
-}
-
-// -------------------------------------------------------------------------
-template< class _TVertex, class _TCost, class _TIndex, class _TIndexCompare >
-void fpa::DataStructures::Graph< _TVertex, _TCost, _TIndex, _TIndexCompare >::
-RemoveVertex( const TIndex& index )
-{
- typename TVertices::iterator i = this->m_Vertices.find( index );
- if( i != this->m_Vertices.end( ) )
- {
- // Delete vertex
- this->m_Vertices.erase( i );
-
- // Delete edges starting from given vertex
- typename TMatrix::iterator mIt = this->m_Matrix.find( index );
- if( mIt != this->m_Matrix.end( ) )
- this->m_Matrix.erase( mIt );
-
- // Delete edges arriving to given vertex
- mIt = this->m_Matrix.begin( );
- for( ; mIt != this->m_Matrix.end( ); ++mIt )
- {
- typename TMatrixRow::iterator rIt = mIt->second.begin( );
- while( rIt != mIt->second.end( ) )
- {
- if( rIt->first == index )
- {
- mIt->second.erase( rIt );
- rIt = mIt->second.begin( );
- }
- else
- ++rIt;
-
- } // elihw
-
- } // rof
-
- } // fi
-}
-
-// -------------------------------------------------------------------------
-template< class _TVertex, class _TCost, class _TIndex, class _TIndexCompare >
-typename
-fpa::DataStructures::Graph< _TVertex, _TCost, _TIndex, _TIndexCompare >::
-TEdges&
-fpa::DataStructures::Graph< _TVertex, _TCost, _TIndex, _TIndexCompare >::
-GetEdges( const TIndex& orig, const TIndex& dest )
-{
- static TEdges null_edges;
- typename TMatrix::iterator o = this->m_Matrix.find( orig );
- if( o != this->m_Matrix.find( orig ) )
- {
- typename TMatrixRow::iterator d = o->second.find( dest );
- if( d == o->second.end( ) )
- {
- null_edges.clear( );
- return( null_edges );
- }
- else
- return( d->second );
- }
- else
- {
- null_edges.clear( );
- return( null_edges );
-
- } // fi
-}
-
-// -------------------------------------------------------------------------
-template< class _TVertex, class _TCost, class _TIndex, class _TIndexCompare >
-const typename
-fpa::DataStructures::Graph< _TVertex, _TCost, _TIndex, _TIndexCompare >::
-TEdges&
-fpa::DataStructures::Graph< _TVertex, _TCost, _TIndex, _TIndexCompare >::
-GetEdges( const TIndex& orig, const TIndex& dest ) const
-{
- static const TEdges null_edges;
- typename TMatrix::iterator o = this->m_Matrix.find( orig );
- if( o != this->m_Matrix.find( orig ) )
- {
- typename TMatrixRow::iterator d = o->second.find( dest );
- if( d == o->second.end( ) )
- return( null_edges );
- else
- return( d->second );
- }
- else
- return( null_edges );
-}
-
-// -------------------------------------------------------------------------
-template< class _TVertex, class _TCost, class _TIndex, class _TIndexCompare >
-bool fpa::DataStructures::Graph< _TVertex, _TCost, _TIndex, _TIndexCompare >::
-HasEdge( const TIndex& orig, const TIndex& dest ) const
-{
- typename TMatrix::const_iterator mIt = this->m_Matrix.find( orig );
- if( mIt != this->m_Matrix.end( ) )
- return( mIt->second.find( dest ) != mIt->second.end( ) );
- else
- return( false );
-}
-
-// -------------------------------------------------------------------------
-template< class _TVertex, class _TCost, class _TIndex, class _TIndexCompare >
-void fpa::DataStructures::Graph< _TVertex, _TCost, _TIndex, _TIndexCompare >::
-RemoveEdge( const TIndex& orig, const TIndex& dest, const TCost& cost )
-{
- typename TMatrix::iterator m = this->m_Matrix.find( orig );
- if( m != this->m_Matrix.end( ) )
- {
- typename TMatrixRow::iterator r = m->second.find( dest );
- if( r != m->second.end( ) )
- {
- typename TEdges::iterator e = r->second.end( );
- for(
- typename TEdges::iterator i = r->second.begin( );
- i != r->second.end( ) && e == r->second.end( );
- ++i
- )
- if( *i == cost )
- e = i;
- if( e != r->second.end( ) )
- {
- r->second.erase( e );
- if( r->second.size( ) == 0 )
- {
- m->second.erase( r );
- if( m->second.size( ) == 0 )
- this->m_Matrix.erase( m );
-
- } // fi
-
- } // fi
-
- } // fi
-
- } // fi
-}
-
-// -------------------------------------------------------------------------
-template< class _TVertex, class _TCost, class _TIndex, class _TIndexCompare >
-void fpa::DataStructures::Graph< _TVertex, _TCost, _TIndex, _TIndexCompare >::
-RemoveEdges( const TIndex& orig, const TIndex& dest )
-{
- typename TMatrix::iterator m = this->m_Matrix.find( orig );
- if( m != this->m_Matrix.end( ) )
- {
- typename TMatrixRow::iterator r = m->second.find( dest );
- if( r != m->second.end( ) )
- {
- m->second.erase( r );
- if( m->second.size( ) == 0 )
- this->m_Matrix.erase( m );
-
- } // fi
-
- } // fi
-
-}
-
-// -------------------------------------------------------------------------
-template< class _TVertex, class _TCost, class _TIndex, class _TIndexCompare >
-std::set< _TIndex, _TIndexCompare >
-fpa::DataStructures::Graph< _TVertex, _TCost, _TIndex, _TIndexCompare >::
-GetSinks( ) const
-{
- std::set< _TIndex, _TIndexCompare > sinks;
-
- typename TVertices::iterator vIt = this->m_Vertices.begin( );
- for( ; vIt != this->m_Vertices.end( ); ++vIt )
- sinks.insert( vIt->first );
- typename TMatrix::iterator mIt = this->m_Matrix.begin( );
- for( ; mIt != this->m_Matrix.end( ); ++mIt )
- sinks.erase( mIt->first );
-
- return( sinks );
-}
-
-// -------------------------------------------------------------------------
-template< class _TVertex, class _TCost, class _TIndex, class _TIndexCompare >
-fpa::DataStructures::Graph< _TVertex, _TCost, _TIndex, _TIndexCompare >::
-Graph( )
- : Superclass( )
-{
-}
-
-// -------------------------------------------------------------------------
-template< class _TVertex, class _TCost, class _TIndex, class _TIndexCompare >
-fpa::DataStructures::Graph< _TVertex, _TCost, _TIndex, _TIndexCompare >::
-~Graph( )
-{
-}
-
-#endif // __fpa__DataStructures__Graph__hxx__
-// eof - $RCSfile$
+++ /dev/null
-// =========================================================================
-// @author Leonardo Florez Valencia
-// @email florez-l@javeriana.edu.co
-// =========================================================================
-#ifndef __fpa__DataStructures__Image__MinimumSpanningTree__h__
-#define __fpa__DataStructures__Image__MinimumSpanningTree__h__
-
-#include <itkImage.h>
-#include <fpa/DataStructures/MinimumSpanningTree.h>
-#include <fpa/DataStructures/Image/Path.h>
-
-namespace fpa
-{
- namespace DataStructures
- {
- namespace Image
- {
- /**
- */
- template< unsigned int _VDim >
- class MinimumSpanningTree
- : public fpa::DataStructures::MinimumSpanningTree< itk::Index< _VDim >, itk::Image< itk::Offset< _VDim >, _VDim > >
- {
- public:
- typedef itk::Index< _VDim > TVertex;
- typedef itk::Image< itk::Offset< _VDim >, _VDim > TDataStructuresImage;
-
- typedef MinimumSpanningTree Self;
- typedef itk::SmartPointer< Self > Pointer;
- typedef itk::SmartPointer< const Self > ConstPointer;
- typedef fpa::DataStructures::MinimumSpanningTree< TVertex, TDataStructuresImage > Superclass;
-
- typedef typename Superclass::TCollision TCollision;
- typedef typename Superclass::TCollisionsRow TCollisionsRow;
- typedef typename Superclass::TCollisions TCollisions;
- typedef typename Superclass::TVertices TVertices;
-
- typedef fpa::DataStructures::Image::Path< _VDim > TPath;
-
- public:
- itkNewMacro( Self );
- itkTypeMacro(
- fpa::DataStructures::Image::MinimumSpanningTree,
- fpa::DataStructures::MinimumSpanningTree
- );
-
- public:
- virtual TVertex GetParent( const TVertex& v ) const override;
- virtual void SetParent( const TVertex& v, const TVertex& p ) override;
-
- void GetPath( typename TPath::Pointer& path, const TVertex& a ) const;
- void GetPath(
- typename TPath::Pointer& path,
- const TVertex& a, const TVertex& b
- ) const;
-
- protected:
- MinimumSpanningTree( );
- virtual ~MinimumSpanningTree( );
-
- private:
- MinimumSpanningTree( const Self& other );
- Self& operator=( const Self& other );
- };
-
- } // ecapseman
-
- } // ecapseman
-
-} // ecapseman
-
-#ifndef ITK_MANUAL_INSTANTIATION
-# include <fpa/DataStructures/Image/MinimumSpanningTree.hxx>
-#endif // ITK_MANUAL_INSTANTIATION
-#endif // __fpa__DataStructures__Image__MinimumSpanningTree__h__
-
-// eof - $RCSfile$
+++ /dev/null
-// =========================================================================
-// @author Leonardo Florez Valencia
-// @email florez-l@javeriana.edu.co
-// =========================================================================
-#ifndef __fpa__DataStructures__Image__MinimumSpanningTree__hxx__
-#define __fpa__DataStructures__Image__MinimumSpanningTree__hxx__
-
-// -------------------------------------------------------------------------
-template< unsigned int _VDim >
-typename fpa::DataStructures::Image::MinimumSpanningTree< _VDim >::
-TVertex fpa::DataStructures::Image::MinimumSpanningTree< _VDim >::
-GetParent( const TVertex& v ) const
-{
- return( v + this->GetPixel( v ) );
-}
-
-// -------------------------------------------------------------------------
-template< unsigned int _VDim >
-void fpa::DataStructures::Image::MinimumSpanningTree< _VDim >::
-SetParent( const TVertex& v, const TVertex& p )
-{
- this->SetPixel( v, p - v );
-}
-
-// -------------------------------------------------------------------------
-template< unsigned int _VDim >
-void fpa::DataStructures::Image::MinimumSpanningTree< _VDim >::
-GetPath( typename TPath::Pointer& path, const TVertex& a ) const
-{
- TVertices v = this->GetAxis( a );
- if( path.IsNull( ) )
- path = TPath::New( );
- path->SetReferenceImage( this );
- typename TVertices::const_iterator vIt = v.begin( );
- for( ; vIt != v.end( ); ++vIt )
- path->AddVertex( *vIt );
-}
-
-// -------------------------------------------------------------------------
-template< unsigned int _VDim >
-void fpa::DataStructures::Image::MinimumSpanningTree< _VDim >::
-GetPath(
- typename TPath::Pointer& path, const TVertex& a, const TVertex& b
- ) const
-{
- TVertices v = this->GetAxis( a, b );
- if( path.IsNull( ) )
- path = TPath::New( );
- path->SetReferenceImage( this );
- typename TVertices::const_iterator vIt = v.begin( );
- for( ; vIt != v.end( ); ++vIt )
- path->AddVertex( *vIt );
-}
-
-// -------------------------------------------------------------------------
-template< unsigned int _VDim >
-fpa::DataStructures::Image::MinimumSpanningTree< _VDim >::
-MinimumSpanningTree( )
- : Superclass( )
-{
-}
-
-// -------------------------------------------------------------------------
-template< unsigned int _VDim >
-fpa::DataStructures::Image::MinimumSpanningTree< _VDim >::
-~MinimumSpanningTree( )
-{
-}
-
-#endif // __fpa__DataStructures__Image__MinimumSpanningTree__hxx__
-// eof - $RCSfile$
+++ /dev/null
-// =========================================================================
-// @author Leonardo Florez Valencia
-// @email florez-l@javeriana.edu.co
-// =========================================================================
-#ifndef __fpa__DataStructures__Image__Path__h__
-#define __fpa__DataStructures__Image__Path__h__
-
-#include <itkPolyLineParametricPath.h>
-#include <itkImageBase.h>
-
-namespace fpa
-{
- namespace DataStructures
- {
- namespace Image
- {
- /**
- */
- template< unsigned int _VDim >
- class Path
- : public itk::PolyLineParametricPath< _VDim >
- {
- public:
- typedef Path Self;
- typedef itk::PolyLineParametricPath< _VDim > Superclass;
- typedef itk::SmartPointer< Self > Pointer;
- typedef itk::SmartPointer< const Self > ConstPointer;
-
- itkStaticConstMacro( Dimension, unsigned int, _VDim );
-
- typedef itk::ImageBase< _VDim > TImageBase;
- typedef typename TImageBase::SpacingType TSpacing;
- typedef typename TImageBase::PointType TPoint;
- typedef typename TImageBase::DirectionType TDirection;
- typedef typename Superclass::ContinuousIndexType TContinuousIndex;
- typedef typename TContinuousIndex::IndexType TIndex;
-
- public:
- itkNewMacro( Self );
- itkTypeMacro( Path, itk::PolyLineParametricPath );
-
- itkGetConstReferenceMacro( Spacing, TSpacing );
- itkGetConstReferenceMacro( Origin, TPoint );
- itkGetConstReferenceMacro( Direction, TDirection );
- itkGetConstReferenceMacro( InverseDirection, TDirection );
-
- itkSetMacro( Origin, TPoint );
-
- public:
- unsigned long GetSize( ) const;
- TContinuousIndex GetContinuousVertex( unsigned long i ) const;
- TIndex GetVertex( unsigned long i ) const;
- TPoint GetPoint( unsigned long i ) const;
-
- virtual void SetSpacing( const TSpacing& spac );
- virtual void SetSpacing( const double spac[ _VDim ] );
- virtual void SetSpacing( const float spac[ _VDim ] );
- virtual void SetOrigin( const double ori[ _VDim ] );
- virtual void SetOrigin( const float ori[ _VDim ] );
- virtual void SetDirection( const TDirection& dir );
-
- template< class _TRefImage >
- inline void SetReferenceImage( const _TRefImage* image )
- {
- this->SetSpacing( image->GetSpacing( ) );
- this->SetOrigin( image->GetOrigin( ) );
- this->SetDirection( image->GetDirection( ) );
- }
-
- virtual void Graft( itk::DataObject* o );
-
- protected:
- Path( );
- virtual ~Path( );
-
- virtual void _ComputeIndexToPhysicalPointMatrices( );
-
- private:
- // Purposely not implemented
- Path( const Self& other );
- Self& operator=( const Self& other );
-
- protected:
- TSpacing m_Spacing;
- TPoint m_Origin;
- TDirection m_Direction;
- TDirection m_InverseDirection;
- TDirection m_IndexToPhysicalPoint;
- TDirection m_PhysicalPointToIndex;
- };
-
- } // ecapseman
-
- } // ecapseman
-
-} // ecapseman
-
-#ifndef ITK_MANUAL_INSTANTIATION
-# include <fpa/DataStructures/Image/Path.hxx>
-#endif // ITK_MANUAL_INSTANTIATION
-
-#endif // __fpa__DataStructures__Image__Path__h__
-
-// eof - $RCSfile$
+++ /dev/null
-// =========================================================================
-// @author Leonardo Florez Valencia
-// @email florez-l@javeriana.edu.co
-// =========================================================================
-
-#ifndef __fpa__DataStructures__Image__Path__hxx__
-#define __fpa__DataStructures__Image__Path__hxx__
-
-#include <itkMath.h>
-#include <itkNumericTraits.h>
-
-// -------------------------------------------------------------------------
-template< unsigned int _VDim >
-unsigned long fpa::DataStructures::Image::Path< _VDim >::
-GetSize( ) const
-{
- return( this->GetVertexList( )->Size( ) );
-}
-
-// -------------------------------------------------------------------------
-template< unsigned int _VDim >
-typename fpa::DataStructures::Image::Path< _VDim >::
-TContinuousIndex fpa::DataStructures::Image::Path< _VDim >::
-GetContinuousVertex( unsigned long i ) const
-{
- return( this->GetVertexList( )->GetElement( i ) );
-}
-
-// -------------------------------------------------------------------------
-template< unsigned int _VDim >
-typename fpa::DataStructures::Image::Path< _VDim >::
-TIndex fpa::DataStructures::Image::Path< _VDim >::
-GetVertex( unsigned long i ) const
-{
- TContinuousIndex cidx = this->GetContinuousVertex( i );
- TIndex idx;
- for( unsigned int d = 0; d < _VDim; ++d )
- idx[ d ] = cidx[ d ];
- return( idx );
-}
-
-// -------------------------------------------------------------------------
-template< unsigned int _VDim >
-typename fpa::DataStructures::Image::Path< _VDim >::
-TPoint fpa::DataStructures::Image::Path< _VDim >::
-GetPoint( unsigned long i ) const
-{
- typedef typename TPoint::CoordRepType _TCoordRep;
- TPoint pnt;
- TContinuousIndex idx = this->GetVertex( i );
- for( unsigned int r = 0; r < _VDim; ++r )
- {
- _TCoordRep sum = itk::NumericTraits< _TCoordRep >::ZeroValue( );
- for( unsigned int c = 0; c < _VDim; ++c )
- sum += this->m_IndexToPhysicalPoint( r, c ) * idx[ c ];
- pnt[ r ] = sum + this->m_Origin[ r ];
-
- } // rof
- return( pnt );
-}
-
-// -------------------------------------------------------------------------
-template< unsigned int _VDim >
-void fpa::DataStructures::Image::Path< _VDim >::
-SetSpacing( const TSpacing& spac )
-{
- if( this->m_Spacing != spac )
- {
- this->m_Spacing = spac;
- this->_ComputeIndexToPhysicalPointMatrices( );
- this->Modified( );
-
- } // fi
-}
-
-// -------------------------------------------------------------------------
-template< unsigned int _VDim >
-void fpa::DataStructures::Image::Path< _VDim >::
-SetSpacing( const double spac[ _VDim ] )
-{
- this->SetSpacing( TSpacing( spac ) );
-}
-
-// -------------------------------------------------------------------------
-template< unsigned int _VDim >
-void fpa::DataStructures::Image::Path< _VDim >::
-SetSpacing( const float spac[ _VDim ] )
-{
- TSpacing s;
- for( unsigned int d = 0; d < _VDim; ++d )
- s[ d ] = spac[ d ];
- this->SetSpacing( s );
-}
-
-// -------------------------------------------------------------------------
-template< unsigned int _VDim >
-void fpa::DataStructures::Image::Path< _VDim >::
-SetOrigin( const double ori[ _VDim ] )
-{
- this->SetOrigin( TPoint( ori ) );
-}
-
-// -------------------------------------------------------------------------
-template< unsigned int _VDim >
-void fpa::DataStructures::Image::Path< _VDim >::
-SetOrigin( const float ori[ _VDim ] )
-{
- this->SetOrigin( TPoint( ori ) );
-}
-
-// -------------------------------------------------------------------------
-template< unsigned int _VDim >
-void fpa::DataStructures::Image::Path< _VDim >::
-SetDirection( const TDirection& dir )
-{
- bool modified = false;
- for( unsigned int r = 0; r < _VDim; r++ )
- {
- for( unsigned int c = 0; c < _VDim; c++ )
- {
- if(
- itk::Math::NotExactlyEquals(
- this->m_Direction[ r ][ c ], dir[ r ][ c ]
- )
- )
- {
- this->m_Direction[ r ][ c ] = dir[ r ][ c ];
- modified = true;
- } // fi
-
- } // rof
-
- } // rof
- if( modified )
- {
- this->_ComputeIndexToPhysicalPointMatrices( );
- this->m_InverseDirection = this->m_Direction.GetInverse( );
- this->Modified( );
-
- } // fi
-}
-
-// -------------------------------------------------------------------------
-template< unsigned int _VDim >
-void fpa::DataStructures::Image::Path< _VDim >::
-Graft( itk::DataObject* o )
-{
- this->Superclass::Graft( o );
- Self* other = dynamic_cast< Self* >( o );
- if( other != NULL )
- {
- this->m_DefaultInputStepSize = other->m_DefaultInputStepSize;
- this->Initialize( );
- for( unsigned long i = 0; i < other->GetSize( ); ++i )
- this->AddVertex( other->GetContinuousVertex( i ) );
- this->m_Spacing = other->m_Spacing;
- this->m_Origin = other->m_Origin;
- this->m_Direction = other->m_Direction;
- this->m_InverseDirection = other->m_InverseDirection;
- this->m_IndexToPhysicalPoint = other->m_IndexToPhysicalPoint;
- this->m_PhysicalPointToIndex = other->m_PhysicalPointToIndex;
-
- } // fi
-}
-
-// -------------------------------------------------------------------------
-template< unsigned int _VDim >
-fpa::DataStructures::Image::Path< _VDim >::
-Path( )
- : Superclass( )
-{
- this->m_Spacing.Fill( 1.0 );
- this->m_Origin.Fill( 0.0 );
- this->m_Direction.SetIdentity( );
- this->m_InverseDirection.SetIdentity( );
- this->m_IndexToPhysicalPoint.SetIdentity( );
- this->m_PhysicalPointToIndex.SetIdentity( );
-}
-
-// -------------------------------------------------------------------------
-template< unsigned int _VDim >
-fpa::DataStructures::Image::Path< _VDim >::
-~Path( )
-{
-}
-
-// -------------------------------------------------------------------------
-template< unsigned int _VDim >
-void fpa::DataStructures::Image::Path< _VDim >::
-_ComputeIndexToPhysicalPointMatrices( )
-{
- TDirection scale;
- scale.Fill( 0.0 );
- for( unsigned int i = 0; i < _VDim; i++ )
- {
- if( this->m_Spacing[ i ] == 0.0 )
- itkExceptionMacro(
- "A spacing of 0 is not allowed: Spacing is " << this->m_Spacing
- );
- scale[ i ][ i ] = this->m_Spacing[ i ];
-
- } // rof
-
- if( vnl_determinant( this->m_Direction.GetVnlMatrix( ) ) == 0.0 )
- itkExceptionMacro(
- << "Bad direction, determinant is 0. Direction is "
- << this->m_Direction
- );
- this->m_IndexToPhysicalPoint = this->m_Direction * scale;
- this->m_PhysicalPointToIndex = this->m_IndexToPhysicalPoint.GetInverse( );
- this->Modified( );
-}
-
-#endif // __fpa__DataStructures__Image__Path__hxx__
-// eof - $RCSfile$
+++ /dev/null
-// =========================================================================
-// @author Leonardo Florez Valencia
-// @email florez-l@javeriana.edu.co
-// =========================================================================
-#ifndef __fpa__DataStructures__Image__Skeleton__h__
-#define __fpa__DataStructures__Image__Skeleton__h__
-
-#include <vector>
-#include <fpa/DataStructures/Graph.h>
-#include <fpa/DataStructures/Image/Path.h>
-
-namespace fpa
-{
- namespace DataStructures
- {
- namespace Image
- {
- /**
- */
- template< unsigned int _VDim >
- class Skeleton
- : public fpa::DataStructures::Graph< typename fpa::DataStructures::Image::Path< _VDim >::TIndex, typename fpa::DataStructures::Image::Path< _VDim >::Pointer, typename fpa::DataStructures::Image::Path< _VDim >::TIndex, typename fpa::DataStructures::Image::Path< _VDim >::TIndex::LexicographicCompare >
- {
- public:
- typedef fpa::DataStructures::Image::Path< _VDim > TPath;
- typedef typename TPath::TIndex TIndex;
- typedef typename TIndex::LexicographicCompare TIndexCompare;
- typedef typename TPath::Pointer TPathPointer;
-
- itkStaticConstMacro( Dimension, unsigned int, _VDim );
-
- typedef fpa::DataStructures::Graph< TIndex, TPathPointer, TIndex, TIndexCompare > Superclass;
- typedef Skeleton Self;
- typedef itk::SmartPointer< Self > Pointer;
- typedef itk::SmartPointer< const Self > ConstPointer;
-
- public:
- itkNewMacro( Self );
- itkTypeMacro( Skeleton, fpa::Image::Graph );
-
- public:
- void AddBranch( TPath* path );
- const TPath* GetBranch( const TIndex& a, const TIndex& b ) const;
-
- std::vector< TIndex > GetEndPoints( ) const;
- std::vector< TIndex > GetBifurcations( ) const;
-
- protected:
- Skeleton( );
- virtual ~Skeleton( );
-
- private:
- // Purposely not implemented
- Skeleton( const Self& other );
- Self& operator=( const Self& other );
- };
-
- } // ecapseman
-
- } // ecapseman
-
-} // ecapseman
-
-#ifndef ITK_MANUAL_INSTANTIATION
-# include <fpa/DataStructures/Image/Skeleton.hxx>
-#endif // ITK_MANUAL_INSTANTIATION
-#endif // __fpa__DataStructures__Image__Skeleton__h__
-// eof - $RCSfile$
+++ /dev/null
-// =========================================================================
-// @author Leonardo Florez Valencia
-// @email florez-l@javeriana.edu.co
-// =========================================================================
-#ifndef __fpa__DataStructures__Image__Skeleton__hxx__
-#define __fpa__DataStructures__Image__Skeleton__hxx__
-
-// -------------------------------------------------------------------------
-template< unsigned int _VDim >
-void fpa::DataStructures::Image::Skeleton< _VDim >::
-AddBranch( TPath* path )
-{
- // Check inputs
- if( path == NULL )
- return;
- unsigned long size = path->GetSize( );
- if( size == 0 )
- return;
- TIndex a = path->GetVertex( 0 );
- TIndex b = path->GetVertex( size - 1 );
- if( this->HasEdge( a, b ) )
- return;
-
- // Add path
- this->SetVertex( a, a );
- this->SetVertex( b, b );
- this->AddEdge( a, b, path );
- this->AddEdge( b, a, path );
- this->Modified( );
-}
-
-// -------------------------------------------------------------------------
-template< unsigned int _VDim >
-const typename fpa::DataStructures::Image::Skeleton< _VDim >::
-TPath* fpa::DataStructures::Image::Skeleton< _VDim >::
-GetBranch( const TIndex& a, const TIndex& b ) const
-{
- static const TPath* null_path = NULL;
- if( this->HasEdge( a, b ) )
- return( this->GetEdges( a, b ).front( ) );
- else
- return( null_path );
-}
-
-// -------------------------------------------------------------------------
-template< unsigned int _VDim >
-std::vector< typename fpa::DataStructures::Image::Skeleton< _VDim >::TIndex >
-fpa::DataStructures::Image::Skeleton< _VDim >::
-GetEndPoints( ) const
-{
- std::vector< TIndex > res;
- typename Superclass::TMatrix::const_iterator mIt = this->BeginEdgesRows( );
- for( ; mIt != this->EndEdgesRows( ); ++mIt )
- {
- unsigned long count = mIt->second.size( );
- if( count == 1 )
- res.push_back( mIt->first );
-
- } // rof
- return( res );
-}
-
-// -------------------------------------------------------------------------
-template< unsigned int _VDim >
-std::vector< typename fpa::DataStructures::Image::Skeleton< _VDim >::TIndex >
-fpa::DataStructures::Image::Skeleton< _VDim >::
-GetBifurcations( ) const
-{
- std::vector< TIndex > res;
- typename Superclass::TMatrix::const_iterator mIt = this->BeginEdgesRows( );
- for( ; mIt != this->EndEdgesRows( ); ++mIt )
- {
- unsigned long count = mIt->second.size( );
- if( count > 1 )
- res.push_back( mIt->first );
-
- } // rof
- return( res );
-}
-
-// -------------------------------------------------------------------------
-template< unsigned int _VDim >
-fpa::DataStructures::Image::Skeleton< _VDim >::
-Skeleton( )
- : Superclass( )
-{
-}
-
-// -------------------------------------------------------------------------
-template< unsigned int _VDim >
-fpa::DataStructures::Image::Skeleton< _VDim >::
-~Skeleton( )
-{
-}
-
-#endif // __fpa__DataStructures__Image__Skeleton__hxx__
-
-// eof - $RCSfile$
+++ /dev/null
-// =========================================================================
-// @author Leonardo Florez Valencia
-// @email florez-l@javeriana.edu.co
-// =========================================================================
-#ifndef __fpa__DataStructures__MinimumSpanningTree__h__
-#define __fpa__DataStructures__MinimumSpanningTree__h__
-
-#include <vector>
-
-namespace fpa
-{
- namespace DataStructures
- {
- /**
- */
- template< class _TVertex, class _Superclass >
- class MinimumSpanningTree
- : public _Superclass
- {
- public:
- typedef MinimumSpanningTree Self;
- typedef _Superclass Superclass;
- typedef itk::SmartPointer< Self > Pointer;
- typedef itk::SmartPointer< const Self > ConstPointer;
-
- typedef _TVertex TVertex;
- typedef std::pair< TVertex, bool > TCollision;
- typedef std::vector< TCollision > TCollisionsRow;
- typedef std::vector< TCollisionsRow > TCollisions;
- typedef std::vector< TVertex > TVertices;
-
- protected:
- typedef std::vector< unsigned long > _TRow;
- typedef std::vector< _TRow > _TMatrix;
-
- public:
- itkTypeMacro( fpa::Base::MinimumSpanningTree, _Superclass );
-
- public:
- const TCollisions& GetCollisions( ) const;
- void SetCollisions( const TCollisions& collisions );
-
- void ClearSeeds( );
- void AddSeed( const TVertex& seed, unsigned long fId );
-
- virtual TVertex GetParent( const TVertex& v ) const = 0;
- virtual void SetParent( const TVertex& v, const TVertex& p ) = 0;
-
- virtual TVertices GetAxis( const TVertex& a ) const;
- virtual TVertices GetAxis( const TVertex& a, const TVertex& b ) const;
-
- protected:
- MinimumSpanningTree( );
- virtual ~MinimumSpanningTree( );
-
- private:
- MinimumSpanningTree( const Self& other );
- Self& operator=( const Self& other );
-
- protected:
- TCollisions m_Collisions;
- _TMatrix m_FrontPaths;
- std::vector< TVertex > m_Seeds;
- };
-
- } // ecapseman
-
-} // ecapseman
-
-#ifndef ITK_MANUAL_INSTANTIATION
-# include <fpa/DataStructures/MinimumSpanningTree.hxx>
-#endif // ITK_MANUAL_INSTANTIATION
-#endif // __fpa__DataStructures__MinimumSpanningTree__h__
-// eof - $RCSfile$
+++ /dev/null
-// =========================================================================
-// @author Leonardo Florez Valencia
-// @email florez-l@javeriana.edu.co
-// =========================================================================
-#ifndef __fpa__DataStructures__MinimumSpanningTree__hxx__
-#define __fpa__DataStructures__MinimumSpanningTree__hxx__
-
-// -------------------------------------------------------------------------
-template< class _TVertex, class _Superclass >
-const typename fpa::DataStructures::MinimumSpanningTree< _TVertex, _Superclass >::
-TCollisions& fpa::DataStructures::MinimumSpanningTree< _TVertex, _Superclass >::
-GetCollisions( ) const
-{
- return( this->m_Collisions );
-}
-
-// -------------------------------------------------------------------------
-template< class _TVertex, class _Superclass >
-void fpa::DataStructures::MinimumSpanningTree< _TVertex, _Superclass >::
-SetCollisions( const TCollisions& collisions )
-{
- static const unsigned long _inf =
- std::numeric_limits< unsigned long >::max( );
- if( this->m_Collisions == collisions )
- return;
-
- this->m_Collisions = collisions;
-
- // Prepare a front graph
- unsigned long N = this->m_Collisions.size( );
- _TMatrix dist( N, _TRow( N, _inf ) );
- this->m_FrontPaths = dist;
- for( unsigned long i = 0; i < N; ++i )
- {
- for( unsigned long j = 0; j < N; ++j )
- {
- if( this->m_Collisions[ i ][ j ].second )
- {
- dist[ i ][ j ] = 1;
- dist[ j ][ i ] = 1;
- this->m_FrontPaths[ i ][ j ] = j;
- this->m_FrontPaths[ j ][ i ] = i;
-
- } // fi
-
- } // rof
- dist[ i ][ i ] = 0;
- this->m_FrontPaths[ i ][ i ] = i;
-
- } // rof
-
- // Use Floyd-Warshall to compute all possible paths between fronts
- for( unsigned long k = 0; k < N; ++k )
- {
- for( unsigned long i = 0; i < N; ++i )
- {
- for( unsigned long j = 0; j < N; ++j )
- {
- // WARNING: you don't want a numeric overflow!!!
- unsigned long dik = dist[ i ][ k ];
- unsigned long dkj = dist[ k ][ j ];
- unsigned long sum = _inf;
- if( dik < _inf && dkj < _inf )
- sum = dik + dkj;
-
- // Ok, continue Floyd-Warshall
- if( sum < dist[ i ][ j ] )
- {
- dist[ i ][ j ] = sum;
- this->m_FrontPaths[ i ][ j ] = this->m_FrontPaths[ i ][ k ];
-
- } // fi
-
- } // rof
-
- } // rof
-
- } // rof
- this->m_Seeds.resize( N );
- this->Modified( );
-}
-
-// -------------------------------------------------------------------------
-template< class _TVertex, class _Superclass >
-void fpa::DataStructures::MinimumSpanningTree< _TVertex, _Superclass >::
-ClearSeeds( )
-{
- this->m_Seeds.clear( );
- this->Modified( );
-}
-
-// -------------------------------------------------------------------------
-template< class _TVertex, class _Superclass >
-void fpa::DataStructures::MinimumSpanningTree< _TVertex, _Superclass >::
-AddSeed( const _TVertex& seed, unsigned long fId )
-{
- this->m_Seeds[ fId - 1 ] = seed;
- this->Modified( );
-}
-
-// -------------------------------------------------------------------------
-template< class _TVertex, class _Superclass >
-typename fpa::DataStructures::MinimumSpanningTree< _TVertex, _Superclass >::
-TVertices fpa::DataStructures::MinimumSpanningTree< _TVertex, _Superclass >::
-GetAxis( const _TVertex& a ) const
-{
- TVertices vertices;
- _TVertex it = a;
- _TVertex p = this->GetParent( it );
- while( it != p )
- {
- vertices.push_back( it );
- it = p;
- p = this->GetParent( it );
-
- } // elihw
- vertices.push_back( it );
- return( vertices );
-}
-
-// -------------------------------------------------------------------------
-template< class _TVertex, class _Superclass >
-typename fpa::DataStructures::MinimumSpanningTree< _TVertex, _Superclass >::
-TVertices fpa::DataStructures::MinimumSpanningTree< _TVertex, _Superclass >::
-GetAxis( const _TVertex& a, const _TVertex& b ) const
-{
- static const unsigned long _inf =
- std::numeric_limits< unsigned long >::max( );
-
- TVertices vertices;
- TVertices pa = this->GetAxis( a );
- TVertices pb = this->GetAxis( b );
- if( pa.size( ) > 0 && pb.size( ) > 0 )
- {
- // Find front identifiers
- unsigned long ia = _inf, ib = _inf;
- unsigned long N = this->m_Seeds.size( );
- for( unsigned long i = 0; i < N; ++i )
- {
- if( this->m_Seeds[ i ] == pa[ pa.size( ) - 1 ] )
- ia = i;
- if( this->m_Seeds[ i ] == pb[ pb.size( ) - 1 ] )
- ib = i;
-
- } // rof
-
- // Check if there is a front-jump between given seeds
- if( ia != ib )
- {
- // Compute front path
- std::vector< long > fpath;
- fpath.push_back( ia );
- while( ia != ib )
- {
- ia = this->m_FrontPaths[ ia ][ ib ];
- fpath.push_back( ia );
-
- } // elihw
-
- // Continue only if both fronts are connected
- unsigned int N = fpath.size( );
- if( N > 0 )
- {
- // First path: from start vertex to first collision
- vertices = this->GetAxis(
- a, this->m_Collisions[ fpath[ 0 ] ][ fpath[ 1 ] ].first
- );
-
- // Intermediary paths
- for( unsigned int i = 1; i < N - 1; ++i )
- {
- TVertices ipath =
- this->GetAxis(
- this->m_Collisions[ fpath[ i - 1 ] ][ fpath[ i ] ].first,
- this->m_Collisions[ fpath[ i + 1 ] ][ fpath[ i ] ].first
- );
- for( long id = 0; id < ipath.size( ); ++id )
- vertices.push_back( ipath[ id ] );
-
- } // rof
-
- // Final path: from last collision to end point
- TVertices lpath =
- this->GetAxis(
- this->m_Collisions[ fpath[ N - 1 ] ][ fpath[ N - 2 ] ].first, b
- );
- for( long id = 0; id < lpath.size( ); ++id )
- vertices.push_back( lpath[ id ] );
-
- } // fi
- }
- else
- {
- // Ignore common part: find common ancestor
- long aIt = pa.size( ) - 1;
- long bIt = pb.size( ) - 1;
- bool cont = true;
- while( aIt >= 0 && bIt >= 0 && cont )
- {
- cont = ( pa[ aIt ] == pb[ bIt ] );
- aIt--;
- bIt--;
-
- } // elihw
- aIt++;
- bIt++;
-
- // Glue both parts
- for( long cIt = 0; cIt <= aIt; ++cIt )
- vertices.push_back( pa[ cIt ] );
- for( ; bIt >= 0; --bIt )
- vertices.push_back( pb[ bIt ] );
-
- } // fi
-
- } // fi
- return( vertices );
-}
-
-// -------------------------------------------------------------------------
-template< class _TVertex, class _Superclass >
-fpa::DataStructures::MinimumSpanningTree< _TVertex, _Superclass >::
-MinimumSpanningTree( )
- : Superclass( )
-{
-}
-
-// -------------------------------------------------------------------------
-template< class _TVertex, class _Superclass >
-fpa::DataStructures::MinimumSpanningTree< _TVertex, _Superclass >::
-~MinimumSpanningTree( )
-{
-}
-
-#endif // __fpa__DataStructures__MinimumSpanningTree__hxx__
-// eof - $RCSfile$
+++ /dev/null
-// =========================================================================
-// @author Leonardo Florez Valencia
-// @email florez-l@javeriana.edu.co
-// =========================================================================
-#ifndef __fpa__VTK__Image__PathToPolyDataFilter__h__
-#define __fpa__VTK__Image__PathToPolyDataFilter__h__
-
-#include <vtkPolyDataAlgorithm.h>
-
-namespace fpa
-{
- namespace VTK
- {
- namespace Image
- {
- /**
- */
- template< class _TPath >
- class PathToPolyDataFilter
- : public vtkPolyDataAlgorithm
- {
- public:
- typedef PathToPolyDataFilter Self;
- typedef _TPath TPath;
-
- public:
- vtkTypeMacro( PathToPolyDataFilter, vtkPolyDataAlgorithm );
-
- public:
- static Self* New( );
-
- const TPath* GetInput( ) const;
- void SetInput( const TPath* path );
-
- protected:
- PathToPolyDataFilter( );
- virtual ~PathToPolyDataFilter( );
-
- int RequestData(
- vtkInformation* information,
- vtkInformationVector** input,
- vtkInformationVector* output
- );
- int RequestInformation(
- vtkInformation* information,
- vtkInformationVector** input,
- vtkInformationVector* output
- );
-
- private:
- // Purposely not implemented
- PathToPolyDataFilter( const Self& );
- void operator=( const Self& );
-
- protected:
- const TPath* m_Path;
- };
-
- } // ecapseman
-
- } // ecapseman
-
-} // ecapseman
-
-#ifndef ITK_MANUAL_INSTANTIATION
-# include <fpa/VTK/Image/PathToPolyDataFilter.hxx>
-#endif // ITK_MANUAL_INSTANTIATION
-#endif // __fpa__VTK__Image__PathToPolyDataFilter__h__
-
-// eof - $RCSfile$
+++ /dev/null
-// =========================================================================
-// @author Leonardo Florez Valencia
-// @email florez-l@javeriana.edu.co
-// =========================================================================
-#ifndef __fpa__VTK__Image__PathToPolyDataFilter__hxx__
-#define __fpa__VTK__Image__PathToPolyDataFilter__hxx__
-
-#include <vtkCellArray.h>
-#include <vtkInformation.h>
-#include <vtkInformationVector.h>
-#include <vtkPointData.h>
-#include <vtkUnsignedIntArray.h>
-#include <vtkSmartPointer.h>
-
-// -------------------------------------------------------------------------
-template< class _TPath >
-typename fpa::VTK::Image::PathToPolyDataFilter< _TPath >::
-Self* fpa::VTK::Image::PathToPolyDataFilter< _TPath >::
-New( )
-{
- return( new Self( ) );
-}
-
-// -------------------------------------------------------------------------
-template< class _TPath >
-const typename
-fpa::VTK::Image::PathToPolyDataFilter< _TPath >::
-TPath* fpa::VTK::Image::PathToPolyDataFilter< _TPath >::
-GetInput( ) const
-{
- return( this->m_Path );
-}
-
-// -------------------------------------------------------------------------
-template< class _TPath >
-void fpa::VTK::Image::PathToPolyDataFilter< _TPath >::
-SetInput( const TPath* path )
-{
- if( this->m_Path != path )
- {
- this->m_Path = path;
- this->Modified( );
-
- } // fi
-}
-
-// -------------------------------------------------------------------------
-template< class _TPath >
-fpa::VTK::Image::PathToPolyDataFilter< _TPath >::
-PathToPolyDataFilter( )
- : vtkPolyDataAlgorithm( ),
- m_Path( NULL )
-{
- this->SetNumberOfInputPorts( 0 );
-}
-
-// -------------------------------------------------------------------------
-template< class _TPath >
-fpa::VTK::Image::PathToPolyDataFilter< _TPath >::
-~PathToPolyDataFilter( )
-{
-}
-
-// -------------------------------------------------------------------------
-template< class _TPath >
-int fpa::VTK::Image::PathToPolyDataFilter< _TPath >::
-RequestData(
- vtkInformation* information,
- vtkInformationVector** input,
- vtkInformationVector* output
- )
-{
- static const unsigned int dim = TPath::PathDimension;
- if( this->m_Path == NULL )
- return( 0 );
-
- // Get output
- vtkInformation* info = output->GetInformationObject( 0 );
- vtkPolyData* out = vtkPolyData::SafeDownCast(
- info->Get( vtkDataObject::DATA_OBJECT( ) )
- );
-
- // Prepare data
- out->SetPoints( vtkSmartPointer< vtkPoints >::New( ) );
- out->SetVerts( vtkSmartPointer< vtkCellArray >::New( ) );
- out->SetLines( vtkSmartPointer< vtkCellArray >::New( ) );
- out->SetPolys( vtkSmartPointer< vtkCellArray >::New( ) );
- out->SetStrips( vtkSmartPointer< vtkCellArray >::New( ) );
- vtkSmartPointer< vtkUnsignedIntArray > darray =
- vtkSmartPointer< vtkUnsignedIntArray >::New( );
- darray->SetNumberOfComponents( 1 );
- out->GetPointData( )->SetScalars( darray );
- vtkPoints* points = out->GetPoints( );
- vtkCellArray* lines = out->GetLines( );
-
- // Assign all data
- const TPath* path = this->GetInput( );
- for( unsigned long i = 0; i < path->GetSize( ); ++i )
- {
- auto pnt = path->GetPoint( i );
- if( dim == 1 )
- points->InsertNextPoint( pnt[ 0 ], 0, 0 );
- else if( dim == 2 )
- points->InsertNextPoint( pnt[ 0 ], pnt[ 1 ], 0 );
- else
- points->InsertNextPoint( pnt[ 0 ], pnt[ 1 ], pnt[ 2 ] );
- darray->InsertNextTuple1( double( i ) );
- if( i > 0 )
- {
- lines->InsertNextCell( 2 );
- lines->InsertCellPoint( points->GetNumberOfPoints( ) - 2 );
- lines->InsertCellPoint( points->GetNumberOfPoints( ) - 1 );
-
- } // fi
-
- } // rof
- return( 1 );
-}
-
-// -------------------------------------------------------------------------
-template< class _TPath >
-int fpa::VTK::Image::PathToPolyDataFilter< _TPath >::
-RequestInformation(
- vtkInformation* information,
- vtkInformationVector** input,
- vtkInformationVector* output
- )
-{
- return( 1 );
-}
-
-#endif // __fpa__VTK__Image__PathToPolyDataFilterFilter__hxx__
-// eof - $RCSfile$
+++ /dev/null
-// =========================================================================
-// @author Leonardo Florez Valencia
-// @email florez-l@javeriana.edu.co
-// =========================================================================
-#ifndef __fpa__VTK__Image__SkeletonToPolyDataFilter__h__
-#define __fpa__VTK__Image__SkeletonToPolyDataFilter__h__
-
-#include <vtkPolyDataAlgorithm.h>
-
-namespace fpa
-{
- namespace VTK
- {
- namespace Image
- {
- /**
- */
- template< class _TSkeleton >
- class SkeletonToPolyDataFilter
- : public vtkPolyDataAlgorithm
- {
- public:
- typedef SkeletonToPolyDataFilter Self;
- typedef _TSkeleton TSkeleton;
-
- public:
- vtkTypeMacro( SkeletonToPolyDataFilter, vtkPolyDataAlgorithm );
-
- public:
- static Self* New( );
-
- const TSkeleton* GetInput( ) const;
- void SetInput( const TSkeleton* sk );
-
- protected:
- SkeletonToPolyDataFilter( );
- virtual ~SkeletonToPolyDataFilter( );
-
- int RequestData(
- vtkInformation* information,
- vtkInformationVector** input,
- vtkInformationVector* output
- );
- int RequestInformation(
- vtkInformation* information,
- vtkInformationVector** input,
- vtkInformationVector* output
- );
-
- private:
- // Purposely not implemented
- SkeletonToPolyDataFilter( const Self& );
- void operator=( const Self& );
-
- protected:
- const TSkeleton* m_Skeleton;
- };
-
- } // ecapseman
-
- } // ecapseman
-
-} // ecapseman
-
-#ifndef ITK_MANUAL_INSTANTIATION
-# include <fpa/VTK/Image/SkeletonToPolyDataFilter.hxx>
-#endif // ITK_MANUAL_INSTANTIATION
-
-#endif // __fpa__VTK__Image__SkeletonToPolyDataFilter__h__
-
-// eof - $RCSfile$
+++ /dev/null
-// =========================================================================
-// @author Leonardo Florez Valencia
-// @email florez-l@javeriana.edu.co
-// =========================================================================
-#ifndef __fpa__VTK__Image__SkeletonToPolyDataFilter__hxx__
-#define __fpa__VTK__Image__SkeletonToPolyDataFilter__hxx__
-
-#include <vtkCellArray.h>
-#include <vtkInformation.h>
-#include <vtkInformationVector.h>
-#include <vtkPointData.h>
-#include <vtkUnsignedIntArray.h>
-#include <vtkSmartPointer.h>
-
-// -------------------------------------------------------------------------
-template< class _TSkeleton >
-typename fpa::VTK::Image::SkeletonToPolyDataFilter< _TSkeleton >::
-Self* fpa::VTK::Image::SkeletonToPolyDataFilter< _TSkeleton >::
-New( )
-{
- return( new Self( ) );
-}
-
-// -------------------------------------------------------------------------
-template< class _TSkeleton >
-const typename
-fpa::VTK::Image::SkeletonToPolyDataFilter< _TSkeleton >::
-TSkeleton* fpa::VTK::Image::SkeletonToPolyDataFilter< _TSkeleton >::
-GetInput( ) const
-{
- return( this->m_Skeleton );
-}
-
-// -------------------------------------------------------------------------
-template< class _TSkeleton >
-void fpa::VTK::Image::SkeletonToPolyDataFilter< _TSkeleton >::
-SetInput( const TSkeleton* sk )
-{
- if( this->m_Skeleton != sk )
- {
- this->m_Skeleton = sk;
- this->Modified( );
-
- } // fi
-}
-
-// -------------------------------------------------------------------------
-template< class _TSkeleton >
-fpa::VTK::Image::SkeletonToPolyDataFilter< _TSkeleton >::
-SkeletonToPolyDataFilter( )
- : vtkPolyDataAlgorithm( ),
- m_Skeleton( NULL )
-{
- this->SetNumberOfInputPorts( 0 );
-}
-
-// -------------------------------------------------------------------------
-template< class _TSkeleton >
-fpa::VTK::Image::SkeletonToPolyDataFilter< _TSkeleton >::
-~SkeletonToPolyDataFilter( )
-{
-}
-
-// -------------------------------------------------------------------------
-template< class _TSkeleton >
-int fpa::VTK::Image::SkeletonToPolyDataFilter< _TSkeleton >::
-RequestData(
- vtkInformation* information,
- vtkInformationVector** input,
- vtkInformationVector* output
- )
-{
- typedef typename _TSkeleton::TPath _TPath;
- static const unsigned int dim = _TPath::PathDimension;
-
- if( this->m_Skeleton == NULL )
- return( 0 );
-
- // Get output
- vtkInformation* info = output->GetInformationObject( 0 );
- vtkPolyData* out = vtkPolyData::SafeDownCast(
- info->Get( vtkDataObject::DATA_OBJECT( ) )
- );
-
- // Prepare data
- out->SetPoints( vtkSmartPointer< vtkPoints >::New( ) );
- out->SetVerts( vtkSmartPointer< vtkCellArray >::New( ) );
- out->SetLines( vtkSmartPointer< vtkCellArray >::New( ) );
- out->SetPolys( vtkSmartPointer< vtkCellArray >::New( ) );
- out->SetStrips( vtkSmartPointer< vtkCellArray >::New( ) );
- vtkSmartPointer< vtkUnsignedIntArray > darray =
- vtkSmartPointer< vtkUnsignedIntArray >::New( );
- darray->SetNumberOfComponents( 1 );
- out->GetPointData( )->SetScalars( darray );
- vtkPoints* points = out->GetPoints( );
- vtkCellArray* lines = out->GetLines( );
-
- // Assign all data
- unsigned int dcount = 0;
- typename TSkeleton::TMatrix::const_iterator mIt = this->m_Skeleton->BeginEdgesRows( );
- for( ; mIt != this->m_Skeleton->EndEdgesRows( ); ++mIt )
- {
- // TODO: mIt->first; --> this is the row index. <--
- typename TSkeleton::TMatrixRow::const_iterator rIt = mIt->second.begin( );
- for( ; rIt != mIt->second.end( ); ++rIt )
- {
- // TODO: rIt->first; --> this is the column index.
- typename TSkeleton::TEdges::const_iterator eIt = rIt->second.begin( );
- for( ; eIt != rIt->second.end( ); ++eIt )
- {
- _TPath* path = *eIt;
- for( unsigned long i = 0; i < path->GetSize( ); ++i )
- {
- auto pnt = path->GetPoint( i );
- if( dim == 1 )
- points->InsertNextPoint( pnt[ 0 ], 0, 0 );
- else if( dim == 2 )
- points->InsertNextPoint( pnt[ 0 ], pnt[ 1 ], 0 );
- else
- points->InsertNextPoint( pnt[ 0 ], pnt[ 1 ], pnt[ 2 ] );
- darray->InsertNextTuple1( double( dcount ) );
- if( i > 0 )
- {
- lines->InsertNextCell( 2 );
- lines->InsertCellPoint( points->GetNumberOfPoints( ) - 2 );
- lines->InsertCellPoint( points->GetNumberOfPoints( ) - 1 );
-
- } // fi
-
- } // rof
- dcount++;
-
- } // rof
-
- } // rof
-
- } // rof
- return( 1 );
-}
-
-// -------------------------------------------------------------------------
-template< class _TSkeleton >
-int fpa::VTK::Image::SkeletonToPolyDataFilter< _TSkeleton >::
-RequestInformation(
- vtkInformation* information,
- vtkInformationVector** input,
- vtkInformationVector* output
- )
-{
- return( 1 );
-}
-
-#endif // __fpa__VTK__Image__SkeletonToPolyDataFilterFilter__hxx__
-// eof - $RCSfile$