$extrastylesheet
Olena  User documentation 2.1
An Image Processing Platform
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
shift.hh
1 // Copyright (C) 2007, 2008, 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 
26 #ifndef MLN_WIN_SHIFT_HH
27 # define MLN_WIN_SHIFT_HH
28 
32 
33 # include <mln/core/window.hh>
34 
35 
36 
37 namespace mln
38 {
39 
40  namespace win
41  {
42 
44  template <typename W>
45  mln_regular(W)
46  shift(const Window<W>& win, const mln_dpsite(W)& dp);
47 
48 
49 # ifndef MLN_INCLUDE_ONLY
50 
51  namespace impl
52  {
53 
54  template <typename W>
55  inline
56  mln_regular(W)
57  shift_(trait::window::definition::unique,
58  const W& win, const mln_dpsite(W)& dp)
59  {
60  mlc_is(mln_trait_window_size(W),
61  trait::window::size::fixed)::check();
62  mln_regular(W) tmp;
63  unsigned n = win.size();
64  for (unsigned i = 0; i < n; ++i)
65  tmp.insert(win.dp(i) + dp);
66  return tmp;
67  }
68 
69  template <typename W>
70  inline
71  mln_regular(W)
72  shift_(trait::window::definition::multiple,
73  const W& win, const mln_dpsite(W)& dp)
74  {
75  mln_regular(W) tmp(win.function());
76  const unsigned nw = win.nwindows();
77  for (unsigned w = 0; w < nw; ++w)
78  tmp.set_window(w, win::shift(win.window(w), dp));
79  return tmp;
80  }
81 
82  } // end of namespace mln::win::impl
83 
84 
85  // Facade.
86  template <typename W>
87  inline
88  mln_regular(W)
89  shift(const Window<W>& win, const mln_dpsite(W)& dp)
90  {
91  mln_trace("win::shift");
92 
93  mlc_is(mln_trait_window_support(W),
94  trait::window::support::regular)::check();
95  mlc_is_not(mln_trait_window_definition(W),
96  trait::window::definition::varying)::check();
97 
98  mln_regular(W) tmp = impl::shift_(mln_trait_window_definition(W)(),
99  exact(win), dp);
100 
101  return tmp;
102  }
103 
104 # endif // ! MLN_INCLUDE_ONLY
105 
106  } // end of namespace mln::win
107 
108 } // end of namespace mln
109 
110 
111 #endif // ! MLN_WIN_SHIFT_HH