$extrastylesheet
Olena  User documentation 2.1
An Image Processing Platform
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
weighted_window_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_WEIGHTED_WINDOW_BASE_HH
28 # define MLN_CORE_INTERNAL_WEIGHTED_WINDOW_BASE_HH
29 
33 
34 # include <mln/core/concept/weighted_window.hh>
35 
36 
37 namespace mln
38 {
39 
40  namespace internal
41  {
42 
49  template <typename W, typename E>
51  {
52 
54  typedef W window;
55 
57  typedef mln_dpsite(W) dpsite;
58 
60  typedef mln_psite(W) psite;
61 
63  typedef mln_site(W) site;
64 
66  bool is_empty() const;
67 
70  unsigned size() const;
71 
75  bool is_centered() const;
76 
80  unsigned delta() const;
81 
85  const mln_dpsite(W)& dp(unsigned i) const;
86 
90  bool has(const mln_dpsite(W)& dp) const;
91 
93  bool is_valid() const;
94 
95  protected:
97  };
98 
99 
100 # ifndef MLN_INCLUDE_ONLY
101 
102  template <typename W, typename E>
103  inline
105  {
106  }
107 
108  template <typename W, typename E>
109  inline
110  bool
112  {
113  return exact(this)->win().is_empty();
114  }
115 
116  template <typename W, typename E>
117  inline
118  unsigned
120  {
121  mlc_equal(mln_trait_window_size(W),
122  trait::window::size::fixed)::check();
123  return exact(this)->win().size();
124  }
125 
126  template <typename W, typename E>
127  inline
128  bool
130  {
131  mlc_equal(mln_trait_window_support(W),
132  trait::window::support::regular)::check();
133  mlc_not_equal(mln_trait_window_definition(W),
134  trait::window::definition::varying)::check();
135  return exact(this)->win().is_centered();
136  }
137 
138  template <typename W, typename E>
139  inline
140  unsigned
142  {
143  mlc_equal(mln_trait_window_support(W),
144  trait::window::support::regular)::check();
145  mlc_not_equal(mln_trait_window_definition(W),
146  trait::window::definition::varying)::check();
147  return exact(this)->win().delta();
148  }
149 
150  template <typename W, typename E>
151  inline
152  const mln_dpsite(W)&
153  weighted_window_base<W,E>::dp(unsigned i) const
154  {
155  mlc_equal(mln_trait_window_support(W),
156  trait::window::support::regular)::check();
157  mlc_equal(mln_trait_window_definition(W),
158  trait::window::definition::unique)::check();
159  mln_precondition(i < this->size());
160  return exact(this)->win().dp(i);
161  }
162 
163  template <typename W, typename E>
164  inline
165  bool
166  weighted_window_base<W,E>::has(const mln_dpsite(W)& dp) const
167  {
168  mlc_equal(mln_trait_window_support(W),
169  trait::window::support::regular)::check();
170  mlc_equal(mln_trait_window_definition(W),
171  trait::window::definition::unique)::check();
172  return exact(this)->win().has(dp);
173  }
174 
175  template <typename W, typename E>
176  inline
177  bool
179  {
180  return true;
181  }
182 
183 # endif // ! MLN_INCLUDE_ONLY
184 
185  } // end of namespace mln::internal
186 
187 } // end of namespace mln
188 
189 
190 #endif // ! MLN_CORE_INTERNAL_WEIGHTED_WINDOW_BASE_HH