1 #ifndef __FPA__IMAGE__MINIMUMSPANNINGTREE__HXX__
2 #define __FPA__IMAGE__MINIMUMSPANNINGTREE__HXX__
6 // -------------------------------------------------------------------------
7 template< unsigned int _NDim >
8 void fpa::Image::MinimumSpanningTree< _NDim >::
9 CopyMetaData( itk::ImageBase< _NDim >* infoImage )
11 this->SetLargestPossibleRegion( infoImage->GetLargestPossibleRegion( ) );
12 this->SetRequestedRegion( infoImage->GetRequestedRegion( ) );
13 this->SetBufferedRegion( infoImage->GetBufferedRegion( ) );
14 this->SetDirection( infoImage->GetDirection( ) );
15 this->SetOrigin( infoImage->GetOrigin( ) );
16 this->SetSpacing( infoImage->GetSpacing( ) );
21 // -------------------------------------------------------------------------
22 template< unsigned int _NDim >
23 void fpa::Image::MinimumSpanningTree< _NDim >::
25 const TVertex& v, const TVertex& p,
26 const short& fid, const double& cost
29 this->Superclass::SetNode( v, p, fid, cost );
33 info.GlobalCost = cost;
34 this->SetPixel( v, info );
37 // -------------------------------------------------------------------------
38 template< unsigned int _NDim >
39 void fpa::Image::MinimumSpanningTree< _NDim >::
42 this->Superclass::Clear( );
44 info.Parent.Fill( 0 );
45 info.FrontId = std::numeric_limits< short >::max( );
46 info.GlobalCost = double( 0 );
47 this->FillBuffer( info );
50 // -------------------------------------------------------------------------
51 template< unsigned int _NDim >
52 typename fpa::Image::MinimumSpanningTree< _NDim >::
53 TPoints fpa::Image::MinimumSpanningTree< _NDim >::
54 GetEuclideanPath( const TVertex& a ) const
57 auto vertices = this->GetPath( a );
58 for( auto vIt = vertices.begin( ); vIt != vertices.end( ); ++vIt )
61 this->TransformIndexToPhysicalPoint( *vIt, pnt );
62 path.push_back( pnt );
68 // -------------------------------------------------------------------------
69 template< unsigned int _NDim >
70 typename fpa::Image::MinimumSpanningTree< _NDim >::
71 TPoints fpa::Image::MinimumSpanningTree< _NDim >::
72 GetEuclideanPath( const TVertex& a, const TVertex& b ) const
75 auto vertices = this->GetPath( a, b );
76 for( auto vIt = vertices.begin( ); vIt != vertices.end( ); ++vIt )
79 this->TransformIndexToPhysicalPoint( *vIt, pnt );
80 path.push_back( pnt );
86 // -------------------------------------------------------------------------
87 template< unsigned int _NDim >
88 bool fpa::Image::MinimumSpanningTree< _NDim >::
89 IsDefinedInEuclideanSpace( ) const
94 // -------------------------------------------------------------------------
95 template< unsigned int _NDim >
96 fpa::Image::MinimumSpanningTree< _NDim >::
97 MinimumSpanningTree( )
102 // -------------------------------------------------------------------------
103 template< unsigned int _NDim >
104 fpa::Image::MinimumSpanningTree< _NDim >::
105 ~MinimumSpanningTree( )
109 // -------------------------------------------------------------------------
110 template< unsigned int _NDim >
111 bool fpa::Image::MinimumSpanningTree< _NDim >::
112 _HasVertex( const TVertex& a ) const
114 return( this->_FrontId( a ) < std::numeric_limits< short >::max( ) );
117 // -------------------------------------------------------------------------
118 template< unsigned int _NDim >
119 short fpa::Image::MinimumSpanningTree< _NDim >::
120 _FrontId( const TVertex& a ) const
122 static const short MAX_ID = std::numeric_limits< short >::max( );
123 if( this->GetRequestedRegion( ).IsInside( a ) )
124 return( this->GetPixel( a ).FrontId );
129 // -------------------------------------------------------------------------
130 template< unsigned int _NDim >
131 void fpa::Image::MinimumSpanningTree< _NDim >::
132 _Path( TVertices& path, const TVertex& a ) const
134 if( this->_HasVertex( a ) )
136 typename TVertex::OffsetType zero;
141 path.push_back( it );
142 it += this->GetPixel( it ).Parent;
144 } while( this->GetPixel( it ).Parent != zero );
149 #endif // __FPA__IMAGE__MINIMUMSPANNINGTREE__HXX__