Milena (Olena)  User documentation 2.0a Id
 All Classes Namespaces Functions Variables Typedefs Enumerator Groups Pages
translate.hh
1 // Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
2 //
3 // This file is part of Olena.
4 //
5 // Olena is free software: you can redistribute it and/or modify it under
6 // the terms of the GNU General Public License as published by the Free
7 // Software Foundation, version 2 of the License.
8 //
9 // Olena is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 // General Public License for more details.
13 //
14 // You should have received a copy of the GNU General Public License
15 // along with Olena. If not, see <http://www.gnu.org/licenses/>.
16 //
17 // As a special exception, you may use this file as part of a free
18 // software project without restriction. Specifically, if other files
19 // instantiate templates or use macros or inline functions from this
20 // file, or you compile this file and link it with other files to produce
21 // an executable, this file does not by itself cause the resulting
22 // executable to be covered by the GNU General Public License. This
23 // exception does not however invalidate any other reasons why the
24 // executable file might be covered by the GNU General Public License.
25 
29 
30 #ifndef MLN_GEOM_TRANSLATE_HH
31 # define MLN_GEOM_TRANSLATE_HH
32 
33 # include <mln/core/concept/image.hh>
34 # include <mln/core/concept/site_set.hh>
35 # include <mln/core/concept/box.hh>
36 
37 # include <mln/core/routine/extend.hh>
38 # include <mln/core/site_set/p_transformed.hh>
39 # include <mln/core/image/imorph/tr_image.hh>
40 
41 # include <mln/data/fill.hh>
42 
43 # include <mln/fun/x2x/translation.hh>
44 
45 # include <mln/literal/zero.hh>
46 
47 # include <mln/geom/bbox.hh>
48 
49 
50 namespace mln
51 {
52 
53  namespace geom
54  {
55 
69  //
70  template <typename I, typename V, typename Ext, typename S>
71  mln_concrete(I)
72  translate(const Image<I>& input,
73  const algebra::vec<mln_site_(I)::dim, V>& ref,
74  const Ext& extension, const Site_Set<S>& output_domain);
75 
76 
78  template <typename I, typename V, typename Ext>
79  mln_concrete(I)
80  translate(const Image<I>& input,
81  const algebra::vec<mln_site_(I)::dim, V>& ref,
82  const Ext& extension);
83 
84 
87  template <typename I, typename V>
88  mln_concrete(I)
89  translate(const Image<I>& input,
90  const algebra::vec<mln_site_(I)::dim, V>& ref);
91 
92 
93 
94 # ifndef MLN_INCLUDE_ONLY
95 
96 
97  template <typename I, typename V, typename Ext, typename S>
98  mln_concrete(I)
99  translate(const Image<I>& input_,
100  const algebra::vec<mln_site_(I)::dim, V>& ref,
101  const Ext& extension_, const Site_Set<S>& output_domain_)
102  {
103  trace::entering("geom::translate");
104 
105  const I& input = exact(input_);
106  const S& output_domain = exact(output_domain_);
107  const mln_exact(Ext)& extension = exact(extension_);
108  //mlc_converts_to(mln_exact(Ext), mln_value(I))::check();
109 
110  mln_precondition(input.is_valid());
111  mln_precondition(output_domain.is_valid());
112 
113  //mln_psite(I) c = geom::bbox(input).center();
115  typedef p_transformed<mln_domain(I), trans_t> trans_domain_t;
116  typedef tr_image<trans_domain_t, I, trans_t> tr_ima_t;
117 
118  trans_t t(ref);
119  trans_domain_t d(input.domain(), t);
120  tr_ima_t tr_ima(d, input, t);
121 
122  mln_concrete(I) output(output_domain);
123  data::fill(output, extend(tr_ima, extension) | output_domain);
124 
125  trace::exiting("geom::translate");
126  return output;
127  }
128 
129 
130  template <typename I, typename V, typename Ext>
131  mln_concrete(I)
132  translate(const Image<I>& input,
133  const algebra::vec<mln_site_(I)::dim, V>& ref,
134  const Ext& extension)
135  {
136  // Old versions of GCC (including Apple GCC 4.0.1) do not parse
137  // correctly `mln_box(I)()'. Hence, we need to typedef
138  // `mln_box(I)' first.
139  typedef mln_domain(I) domain_t;
140  return translate(input, ref, extension, domain_t());
141  }
142 
143 
144  template <typename I, typename V>
145  mln_concrete(I)
146  translate(const Image<I>& input,
147  const algebra::vec<mln_site_(I)::dim, V>& ref)
148  {
149  return translate(input, ref, literal::zero);
150  }
151 
152 
153 # endif // ! MLN_INCLUDE_ONLY
154 
155 
156  } // end of namespace mln::geom
157 
158 } // end of namespace mln
159 
160 
161 #endif // ! MLN_GEOM_TRANSLATE_HH