• Main Page
  • Related Pages
  • Modules
  • Namespaces
  • Classes
  • Files
  • File List

translate.hh

00001 // Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
00002 //
00003 // This file is part of Olena.
00004 //
00005 // Olena is free software: you can redistribute it and/or modify it under
00006 // the terms of the GNU General Public License as published by the Free
00007 // Software Foundation, version 2 of the License.
00008 //
00009 // Olena is distributed in the hope that it will be useful,
00010 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00011 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012 // General Public License for more details.
00013 //
00014 // You should have received a copy of the GNU General Public License
00015 // along with Olena.  If not, see <http://www.gnu.org/licenses/>.
00016 //
00017 // As a special exception, you may use this file as part of a free
00018 // software project without restriction.  Specifically, if other files
00019 // instantiate templates or use macros or inline functions from this
00020 // file, or you compile this file and link it with other files to produce
00021 // an executable, this file does not by itself cause the resulting
00022 // executable to be covered by the GNU General Public License.  This
00023 // exception does not however invalidate any other reasons why the
00024 // executable file might be covered by the GNU General Public License.
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       //mlc_converts_to(mln_exact(Ext), mln_value(I))::check();
00109 
00110       mln_precondition(input.is_valid());
00111       mln_precondition(output_domain.is_valid());
00112 
00113       //mln_psite(I) c = geom::bbox(input).center();
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       // Old versions of GCC (including Apple GCC 4.0.1) do not parse
00137       // correctly `mln_box(I)()'.  Hence, we need to typedef
00138       // `mln_box(I)' first.
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   } // end of namespace mln::geom
00157 
00158 } // end of namespace mln
00159 
00160 
00161 #endif // ! MLN_GEOM_TRANSLATE_HH

Generated on Tue Oct 4 2011 15:24:45 for Milena (Olena) by  doxygen 1.7.1