00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 
00018 
00019 
00020 
00021 
00022 
00023 
00024 
00025 
00026 #ifndef MLN_TRANSFORM_INTERNAL_INFLUENCE_ZONE_FUNCTOR_HH
00027 # define MLN_TRANSFORM_INTERNAL_INFLUENCE_ZONE_FUNCTOR_HH
00028 
00032 
00033 # include <mln/core/routine/duplicate.hh>
00034 
00035 
00036 
00037 namespace mln
00038 {
00039 
00040   namespace transform
00041   {
00042 
00043     namespace internal
00044     {
00045 
00046       template <typename I>
00047       struct influence_zone_functor
00048       {
00049         typedef mln_value(I) V;
00050         typedef mln_psite(I)  P;
00051 
00052         influence_zone_functor();
00053         influence_zone_functor(const V& background_value);
00054 
00055         mln_concrete(I) output;
00056 
00057         void init(const I& input);
00058         bool inqueue_p_wrt_input_p(const V& input_p);
00059         bool inqueue_p_wrt_input_n(const V& input_n);
00060         void init_p(const P&);
00061         void process(const P& p, const P& n);
00062 
00063         void init_(const I& input);
00064         bool inqueue_p_wrt_input_p_(const V& input_p);
00065         bool inqueue_p_wrt_input_n_(const V& input_n);
00066         void init_p_(unsigned);
00067         void process_(unsigned p, unsigned n);
00068 
00069         V background_value_;
00070       };
00071 
00072 
00073 # ifndef MLN_INCLUDE_ONLY
00074 
00075 
00076       template <typename I>
00077       inline
00078       influence_zone_functor<I>::influence_zone_functor()
00079       {
00080         background_value_ = literal::zero;
00081       }
00082 
00083 
00084       template <typename I>
00085       inline
00086       influence_zone_functor<I>::influence_zone_functor(const V& background_value)
00087       {
00088         background_value_ = background_value;
00089       }
00090 
00091 
00092       
00093 
00094       template <typename I>
00095       inline
00096       void
00097       influence_zone_functor<I>::init(const I& input)
00098       {
00099         output = duplicate(input);
00100       }
00101 
00102       template <typename I>
00103       inline
00104       bool
00105       influence_zone_functor<I>::inqueue_p_wrt_input_p(const V& input_p)
00106       {
00107         return input_p != background_value_;
00108       }
00109 
00110       template <typename I>
00111       inline
00112       bool
00113       influence_zone_functor<I>::inqueue_p_wrt_input_n(const V& input_n)
00114       {
00115         return input_n == background_value_;
00116       }
00117 
00118       template <typename I>
00119       inline
00120       void
00121       influence_zone_functor<I>::init_p(const P&)
00122       {
00123       }
00124 
00125       template <typename I>
00126       inline
00127       void influence_zone_functor<I>::process(const P& p, const P& n)
00128       {
00129         output(n) = output(p);
00130       }
00131 
00132 
00133 
00134       
00135 
00136       template <typename I>
00137       inline
00138       void
00139       influence_zone_functor<I>::init_(const I& input)
00140       {
00141         output = duplicate(input);
00142       }
00143 
00144       template <typename I>
00145       inline
00146       bool
00147       influence_zone_functor<I>::inqueue_p_wrt_input_p_(const V& input_p)
00148       {
00149         return input_p != background_value_;
00150       }
00151 
00152       template <typename I>
00153       inline
00154       bool
00155       influence_zone_functor<I>::inqueue_p_wrt_input_n_(const V& input_n)
00156       {
00157         return input_n == background_value_;
00158       }
00159 
00160       template <typename I>
00161       inline
00162       void
00163       influence_zone_functor<I>::init_p_(unsigned)
00164       {
00165       }
00166 
00167       template <typename I>
00168       inline
00169       void influence_zone_functor<I>::process_(unsigned p, unsigned n)
00170       {
00171         output.element(n) = output.element(p);
00172       }
00173 
00174 
00175 # endif // ! MLN_INCLUDE_ONLY
00176 
00177     } 
00178 
00179   } 
00180 
00181 } 
00182 
00183 
00184 #endif // ! MLN_TRANSFORM_INTERNAL_INFLUENCE_ZONE_FUNCTOR_HH