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 
00029 
00030 #ifndef MLN_GEOM_TRANSLATE_HH
00031 # define MLN_GEOM_TRANSLATE_HH
00032 
00033 # include <mln/core/concept/image.hh>
00034 # include <mln/core/concept/site_set.hh>
00035 # include <mln/core/concept/box.hh>
00036 
00037 # include <mln/core/routine/extend.hh>
00038 # include <mln/core/site_set/p_transformed.hh>
00039 # include <mln/core/image/imorph/tr_image.hh>
00040 
00041 # include <mln/data/fill.hh>
00042 
00043 # include <mln/fun/x2x/translation.hh>
00044 
00045 # include <mln/literal/zero.hh>
00046 
00047 # include <mln/geom/bbox.hh>
00048 
00049 
00050 namespace mln
00051 {
00052 
00053   namespace geom
00054   {
00055 
00069     
00070     template <typename I, typename V, typename Ext, typename S>
00071     mln_concrete(I)
00072     translate(const Image<I>& input,
00073               const algebra::vec<mln_site_(I)::dim, V>& ref,
00074               const Ext& extension, const Site_Set<S>& output_domain);
00075 
00076 
00078     template <typename I, typename V, typename Ext>
00079     mln_concrete(I)
00080     translate(const Image<I>& input,
00081               const algebra::vec<mln_site_(I)::dim, V>& ref,
00082               const Ext& extension);
00083 
00084 
00087     template <typename I, typename V>
00088     mln_concrete(I)
00089     translate(const Image<I>& input,
00090               const algebra::vec<mln_site_(I)::dim, V>& ref);
00091 
00092 
00093 
00094 # ifndef MLN_INCLUDE_ONLY
00095 
00096 
00097     template <typename I, typename V, typename Ext, typename S>
00098     mln_concrete(I)
00099     translate(const Image<I>& input_,
00100               const algebra::vec<mln_site_(I)::dim, V>& ref,
00101               const Ext& extension_, const Site_Set<S>& output_domain_)
00102     {
00103       trace::entering("geom::translate");
00104 
00105       const I& input = exact(input_);
00106       const S& output_domain = exact(output_domain_);
00107       const mln_exact(Ext)& extension = exact(extension_);
00108       
00109 
00110       mln_precondition(input.is_valid());
00111       mln_precondition(output_domain.is_valid());
00112 
00113       
00114       typedef fun::x2x::translation<mln_site_(I)::dim, V> trans_t;
00115       typedef p_transformed<mln_domain(I), trans_t> trans_domain_t;
00116       typedef tr_image<trans_domain_t, I, trans_t> tr_ima_t;
00117 
00118       trans_t t(ref);
00119       trans_domain_t d(input.domain(), t);
00120       tr_ima_t tr_ima(d, input, t);
00121 
00122       mln_concrete(I) output(output_domain);
00123       data::fill(output, extend(tr_ima, extension) | output_domain);
00124 
00125       trace::exiting("geom::translate");
00126       return output;
00127     }
00128 
00129 
00130     template <typename I, typename V, typename Ext>
00131     mln_concrete(I)
00132     translate(const Image<I>& input,
00133               const algebra::vec<mln_site_(I)::dim, V>& ref,
00134               const Ext& extension)
00135     {
00136       
00137       
00138       
00139       typedef mln_domain(I) domain_t;
00140       return translate(input, ref, extension, domain_t());
00141     }
00142 
00143 
00144     template <typename I, typename V>
00145     mln_concrete(I)
00146     translate(const Image<I>& input,
00147               const algebra::vec<mln_site_(I)::dim, V>& ref)
00148     {
00149       return translate(input, ref, literal::zero);
00150     }
00151 
00152 
00153 # endif // ! MLN_INCLUDE_ONLY
00154 
00155 
00156   } 
00157 
00158 } 
00159 
00160 
00161 #endif // ! MLN_GEOM_TRANSLATE_HH