]> Creatis software - FrontAlgorithms.git/blob - lib/fpa/Image/PathsToImageFilter.hxx
487b9c8ed3d115df54d0f32f90460d5e174e229d
[FrontAlgorithms.git] / lib / fpa / Image / PathsToImageFilter.hxx
1 // =========================================================================
2 // @author Leonardo Florez Valencia
3 // @email florez-l@javeriana.edu.co
4 // =========================================================================
5
6 #ifndef __fpa__Image__PathsToImageFilter__hxx__
7 #define __fpa__Image__PathsToImageFilter__hxx__
8
9 // -------------------------------------------------------------------------
10 template< class _TMST, class _TOutputPixelValue >
11 void fpa::Image::PathsToImageFilter< _TMST, _TOutputPixelValue >::
12 AddPath(
13   const TIndex& start, const TIndex& end,
14   const TOutputPixelValue& r,
15   const TOutputPixelValue& g,
16   const TOutputPixelValue& b
17   )
18 {
19   if( start != end )
20   {
21     TPathData d;
22     d.Start = start;
23     d.End = end;
24     d.Red = r;
25     d.Green = g;
26     d.Blue = b;
27     this->m_Paths.push_back( d );
28     this->Modified( );
29
30   } // fi
31 }
32
33 // -------------------------------------------------------------------------
34 template< class _TMST, class _TOutputPixelValue >
35 fpa::Image::PathsToImageFilter< _TMST, _TOutputPixelValue >::
36 PathsToImageFilter( )
37   : Superclass( )
38 {
39 }
40
41 // -------------------------------------------------------------------------
42 template< class _TMST, class _TOutputPixelValue >
43 fpa::Image::PathsToImageFilter< _TMST, _TOutputPixelValue >::
44 ~PathsToImageFilter( )
45 {
46 }
47
48 // -------------------------------------------------------------------------
49 template< class _TMST, class _TOutputPixelValue >
50 void fpa::Image::PathsToImageFilter< _TMST, _TOutputPixelValue >::
51 GenerateData( )
52 {
53   TOutputPixel color;
54   color.Fill( 0 );
55
56   const TMST* mst = this->GetInput( );
57   TOutputImage* output = this->GetOutput( );
58   output->SetBufferedRegion( mst->GetBufferedRegion( ) );
59   output->Allocate( );
60   output->FillBuffer( color );
61
62   typename TPaths::const_iterator d = this->m_Paths.begin( );
63   for( ; d != this->m_Paths.end( ); ++d )
64   {
65     typename TMST::TVertices path = mst->GetPath( d->Start, d->End );
66     color[ 0 ] = d->Red;
67     color[ 1 ] = d->Green;
68     color[ 2 ] = d->Blue;
69     color[ 3 ] = std::numeric_limits< TOutputPixelValue >::max( );
70     typename TMST::TVertices::const_iterator i = path.begin( );
71     for( ; i != path.end( ); ++i )
72       output->SetPixel( *i, color );
73
74   } // rof
75 }
76
77 #endif // __fpa__Image__PathsToImageFilter__hxx__
78
79 // eof - $RCSfile$