$extrastylesheet
Olena  User documentation 2.1
An Image Processing Platform
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
box_impl.hh
1 // Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012 EPITA Research and
2 // Development 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_BOX_IMPL_HH
28 # define MLN_CORE_INTERNAL_BOX_IMPL_HH
29 
36 # include <mln/core/internal/force_exact.hh>
37 
38 
39 namespace mln
40 {
41 
42  // Forward declaration
43 
44  namespace internal
45  {
46 
47  // box_impl
48 
55  template <unsigned n, typename C, typename E>
56  struct box_impl_;
57 
58  template <typename C, typename E> // FIXME: Add an extra param to replace 'unsigned'.
59  struct box_impl_<3, C, E>
60  {
62  unsigned nslis() const;
63 
65  C min_sli() const;
66 
68  C max_sli() const;
69 
71  unsigned nrows() const;
72 
74  C min_row() const;
75 
77  C max_row() const;
78 
80  unsigned ncols() const;
81 
83  C min_col() const;
84 
86  C max_col() const;
87 
89  unsigned width() const;
90 
92  unsigned height() const;
93 
95  unsigned depth() const;
96  };
97 
98  template <typename C, typename E> // FIXME: Add an extra param to replace 'unsigned'.
99  struct box_impl_<2, C, E>
100  {
102  unsigned nrows() const;
103 
105  C min_row() const;
106 
108  C max_row() const;
109 
111  unsigned ncols() const;
112 
114  C min_col() const;
115 
117  C max_col() const;
118 
120  unsigned width() const;
121 
123  unsigned height() const;
124 
125  };
126 
127  template <typename C, typename E> // FIXME: Add an extra param to replace 'unsigned'.
128  struct box_impl_<1, C, E>
129  {
131  unsigned ninds() const;
132 
134  C min_ind() const;
135 
137  C max_ind() const;
138  };
139 
140 
141 # ifndef MLN_INCLUDE_ONLY
142 
143  // box_impl
144 
145  // 3
146 
147  template <typename C, typename E>
148  inline
149  unsigned box_impl_<3, C, E>::nslis() const
150  {
151  return internal::force_exact<E>(*this).bbox().len(0);
152  }
153 
154  template <typename C, typename E>
155  inline
157  {
158  return internal::force_exact<E>(*this).bbox().pmin()[0];
159  }
160 
161  template <typename C, typename E>
162  inline
164  {
165  return internal::force_exact<E>(*this).bbox().pmax()[0];
166  }
167 
168  template <typename C, typename E>
169  inline
170  unsigned box_impl_<3, C, E>::nrows() const
171  {
172  return internal::force_exact<E>(*this).bbox().len(1);
173  }
174 
175  template <typename C, typename E>
176  inline
178  {
179  return internal::force_exact<E>(*this).bbox().pmin()[1];
180  }
181 
182  template <typename C, typename E>
183  inline
185  {
186  return internal::force_exact<E>(*this).bbox().pmax()[1];
187  }
188 
189  template <typename C, typename E>
190  inline
191  unsigned box_impl_<3, C, E>::ncols() const
192  {
193  return internal::force_exact<E>(*this).bbox().len(2);
194  }
195 
196  template <typename C, typename E>
197  inline
199  {
200  return internal::force_exact<E>(*this).bbox().pmin()[2];
201  }
202 
203  template <typename C, typename E>
204  inline
206  {
207  return internal::force_exact<E>(*this).bbox().pmax()[2];
208  }
209 
210 
211  template <typename C, typename E>
212  inline
213  unsigned box_impl_<3, C, E>::width() const
214  {
215  return internal::force_exact<E>(*this).bbox().len(2);
216  }
217 
218  template <typename C, typename E>
219  inline
220  unsigned box_impl_<3, C, E>::height() const
221  {
222  return internal::force_exact<E>(*this).bbox().len(1);
223  }
224 
225  template <typename C, typename E>
226  inline
227  unsigned box_impl_<3, C, E>::depth() const
228  {
229  return internal::force_exact<E>(*this).bbox().len(0);
230  }
231 
232 
233  // 2
234 
235  template <typename C, typename E>
236  inline
237  unsigned box_impl_<2, C, E>::nrows() const
238  {
239  return internal::force_exact<E>(*this).bbox().len(0);
240  }
241 
242  template <typename C, typename E>
243  inline
245  {
246  return internal::force_exact<E>(*this).bbox().pmin()[0];
247  }
248 
249  template <typename C, typename E>
250  inline
252  {
253  return internal::force_exact<E>(*this).bbox().pmax()[0];
254  }
255 
256  template <typename C, typename E>
257  inline
258  unsigned box_impl_<2, C, E>::ncols() const
259  {
260  return internal::force_exact<E>(*this).bbox().len(1);
261  }
262 
263  template <typename C, typename E>
264  inline
266  {
267  return internal::force_exact<E>(*this).bbox().pmin()[1];
268  }
269 
270  template <typename C, typename E>
271  inline
273  {
274  return internal::force_exact<E>(*this).bbox().pmax()[1];
275  }
276 
277  template <typename C, typename E>
278  inline
279  unsigned box_impl_<2, C, E>::width() const
280  {
281  return internal::force_exact<E>(*this).bbox().len(1);
282  }
283 
284  template <typename C, typename E>
285  inline
286  unsigned box_impl_<2, C, E>::height() const
287  {
288  return internal::force_exact<E>(*this).bbox().len(0);
289  }
290 
291  // 1
292 
293  template <typename C, typename E>
294  inline
295  unsigned box_impl_<1, C, E>::ninds() const
296  {
297  return internal::force_exact<E>(*this).bbox().len(0);
298  }
299 
300  template <typename C, typename E>
301  inline
303  {
304  return internal::force_exact<E>(*this).bbox().pmin()[0];
305  }
306 
307  template <typename C, typename E>
308  inline
310  {
311  return internal::force_exact<E>(*this).bbox().pmax()[0];
312  }
313 
314 # endif // ! MLN_INCLUDE_ONLY
315 
316  } // end of namespace mln::internal
317 
318 } // end of namespace mln
319 
320 
321 #endif // ! MLN_CORE_INTERNAL_BOX_IMPL_HH