$extrastylesheet
Olena  User documentation 2.1
An Image Processing Platform
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
neighborhood_base.hh
1 // Copyright (C) 2008, 2009, 2012 EPITA Research and Development
2 // Laboratory (LRDE)
3 //
4 // This file is part of Olena.
5 //
6 // Olena is free software: you can redistribute it and/or modify it under
7 // the terms of the GNU General Public License as published by the Free
8 // Software Foundation, version 2 of the License.
9 //
10 // Olena is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 // General Public License for more details.
14 //
15 // You should have received a copy of the GNU General Public License
16 // along with Olena. If not, see <http://www.gnu.org/licenses/>.
17 //
18 // As a special exception, you may use this file as part of a free
19 // software project without restriction. Specifically, if other files
20 // instantiate templates or use macros or inline functions from this
21 // file, or you compile this file and link it with other files to produce
22 // an executable, this file does not by itself cause the resulting
23 // executable to be covered by the GNU General Public License. This
24 // exception does not however invalidate any other reasons why the
25 // executable file might be covered by the GNU General Public License.
26 
27 #ifndef MLN_CORE_INTERNAL_NEIGHBORHOOD_BASE_HH
28 # define MLN_CORE_INTERNAL_NEIGHBORHOOD_BASE_HH
29 
36 
37 # include <mln/core/concept/neighborhood.hh>
38 # include <mln/core/concept/window.hh>
39 
40 
41 namespace mln
42 {
43 
44 
45  // Forward declaration.
46  template <typename W> class neighb;
47  namespace win
48  {
49  template <unsigned n, typename W, typename F>
50  class multiple_size;
51  }
52 
53 
54  namespace internal
55  {
56 
57  template <typename W, typename E>
59  : public Neighborhood<E>
60  {
61  };
62 
63  template <typename W, typename F, typename E>
64  struct neighborhood_extra_impl< win::multiple_size<2,W,F>, E >
65  : public Neighborhood<E>
66  {
67 
71 
73  {
74  W win = internal::force_exact<E>(*this).win().window_(1); // True, so object.
75  neighb<W> nbh(win);
76  return nbh;
77  }
78 
82 
84  {
85  W win = internal::force_exact<E>(*this).win().window_(0); // False, so background.
86  neighb<W> nbh(win);
87  return nbh;
88  }
89 
90  };
91 
92 
93 
94 
95  template <typename W, typename E>
97  {
98  // Optional methods...
99 
102  unsigned size() const;
103 
106  unsigned delta() const;
107 
110  const mln_dpsite(W)& dp(unsigned i) const;
111 
112  // end of Optional methods.
113  };
114 
115 
122  template <typename W, typename E>
124  {
126  typedef W window;
127 
129  typedef mln_dpsite(W) dpsite;
130 
132  typedef mln_psite(W) psite;
133 
135  typedef mln_site(W) site;
136 
138  bool is_valid() const;
139 
140  protected:
142  };
143 
144 
145 
146 
147 # ifndef MLN_INCLUDE_ONLY
148 
149 
150  // neighborhood_base
151 
152  template <typename W, typename E>
153  inline
155  {
156  }
157 
158  template <typename W, typename E>
159  inline
160  bool
162  {
163  return true;
164  }
165 
166  // neighborhood_impl
167 
168  template <typename W, typename E>
169  inline
170  unsigned
172  {
173  mlc_is(mln_trait_window_size(W),
174  trait::window::size::fixed)::check();
175  return exact(this)->win().size();
176  }
177 
178  template <typename W, typename E>
179  inline
180  unsigned
182  {
183  mlc_is(mln_trait_window_support(W),
184  trait::window::support::regular)::check();
185  mlc_is_not(mln_trait_window_definition(W),
186  trait::window::definition::varying)::check();
187  return exact(this)->win().delta();
188  }
189 
190  template <typename W, typename E>
191  inline
192  const mln_dpsite(W)&
193  neighborhood_impl<W,E>::dp(unsigned i) const
194  {
195  mlc_is(mln_trait_window_support(W),
196  trait::window::support::regular)::check();
197  mlc_is(mln_trait_window_definition(W),
198  trait::window::definition::unique)::check();
199  return exact(this)->win().dp(i);
200  }
201 
202 # endif // ! MLN_INCLUDE_ONLY
203 
204  } // end of namespace mln::internal
205 
206 } // end of namespace mln
207 
208 
209 #endif // ! MLN_CORE_INTERNAL_NEIGHBORHOOD_BASE_HH