]> Creatis software - FrontAlgorithms.git/blob - lib/fpa/Base/ImageSkeleton.hxx
On my way... it does not work yet, but I think I'm on the good track.
[FrontAlgorithms.git] / lib / fpa / Base / ImageSkeleton.hxx
1 #ifndef __FPA__BASE__IMAGESKELETON__HXX__
2 #define __FPA__BASE__IMAGESKELETON__HXX__
3
4 // -------------------------------------------------------------------------
5 template< class _TMST >
6 void fpa::Base::ImageSkeleton< _TMST >::
7 AddBranch( const TVertex& a, const TVertex& b )
8 {
9   if( this->m_MinimumSpanningTree.IsNull( ) )
10     return;
11
12   // Check if the branch already exists
13   bool found = false;
14   auto arIt = this->Get( ).find( a );
15   if( arIt != this->Get( ).end( ) )
16     found = ( arIt->second.find( b ) != arIt->second.end( ) );
17   if( found )
18     return;
19
20   // Create path
21   auto vertices = this->m_MinimumSpanningTree->GetPath( a, b );
22   typename TPath::Pointer path = TPath::New( );
23   for( auto vIt = vertices.begin( ); vIt != vertices.end( ); ++vIt )
24     path->AddVertex( *vIt );
25
26   // Assign path vertices
27   path->SetReferenceImage( this->m_MinimumSpanningTree );
28   this->Get( )[ a ][ b ] = path;
29   this->Modified( );
30 }
31
32 // -------------------------------------------------------------------------
33 template< class _TMST >
34 const typename fpa::Base::ImageSkeleton< _TMST >::
35 TPath* fpa::Base::ImageSkeleton< _TMST >::
36 GetBranch( const TVertex& a, const TVertex& b ) const
37 {
38   auto aIt = this->Get( ).find( a );
39   if( aIt != this->Get( ).end( ) )
40   {
41     auto bIt = aIt->second.find( b );
42     if( bIt != aIt->second.end( ) )
43       return( bIt->second.GetPointer( ) );
44     else
45       return( NULL );
46   }
47   else
48     return( NULL );
49 }
50
51 // -------------------------------------------------------------------------
52 template< class _TMST >
53 fpa::Base::ImageSkeleton< _TMST >::
54 ImageSkeleton( )
55   : Superclass( )
56 {
57 }
58
59 // -------------------------------------------------------------------------
60 template< class _TMST >
61 fpa::Base::ImageSkeleton< _TMST >::
62 ~ImageSkeleton( )
63 {
64 }
65
66 #endif // __FPA__BASE__IMAGESKELETON__HXX__
67
68 // eof - $RCSfile$