Milena (Olena)  User documentation 2.0a Id
 All Classes Namespaces Functions Variables Typedefs Enumerator Groups Pages
box_impl.hh
1 // Copyright (C) 2007, 2008, 2009, 2010, 2011 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 
53  template <unsigned n, typename C, typename E>
54  struct box_impl_;
55 
56  template <typename C, typename E> // FIXME: Add an extra param to replace 'unsigned'.
57  struct box_impl_<3, C, E>
58  {
60  unsigned nslis() const;
61 
63  C min_sli() const;
64 
66  C max_sli() const;
67 
69  unsigned nrows() const;
70 
72  C min_row() const;
73 
75  C max_row() const;
76 
78  unsigned ncols() const;
79 
81  C min_col() const;
82 
84  C max_col() const;
85 
87  unsigned width() const;
88 
90  unsigned height() const;
91 
93  unsigned depth() const;
94  };
95 
96  template <typename C, typename E> // FIXME: Add an extra param to replace 'unsigned'.
97  struct box_impl_<2, C, E>
98  {
100  unsigned nrows() const;
101 
103  C min_row() const;
104 
106  C max_row() const;
107 
109  unsigned ncols() const;
110 
112  C min_col() const;
113 
115  C max_col() const;
116 
118  unsigned width() const;
119 
121  unsigned height() const;
122 
123  };
124 
125  template <typename C, typename E> // FIXME: Add an extra param to replace 'unsigned'.
126  struct box_impl_<1, C, E>
127  {
129  unsigned ninds() const;
130 
132  C min_ind() const;
133 
135  C max_ind() const;
136  };
137 
138 
139 # ifndef MLN_INCLUDE_ONLY
140 
141  // box_impl
142 
143  // 3
144 
145  template <typename C, typename E>
146  inline
147  unsigned box_impl_<3, C, E>::nslis() const
148  {
149  return internal::force_exact<E>(*this).bbox().len(0);
150  }
151 
152  template <typename C, typename E>
153  inline
154  C box_impl_<3, C, E>::min_sli() const
155  {
156  return internal::force_exact<E>(*this).bbox().pmin()[0];
157  }
158 
159  template <typename C, typename E>
160  inline
161  C box_impl_<3, C, E>::max_sli() const
162  {
163  return internal::force_exact<E>(*this).bbox().pmax()[0];
164  }
165 
166  template <typename C, typename E>
167  inline
168  unsigned box_impl_<3, C, E>::nrows() const
169  {
170  return internal::force_exact<E>(*this).bbox().len(1);
171  }
172 
173  template <typename C, typename E>
174  inline
175  C box_impl_<3, C, E>::min_row() const
176  {
177  return internal::force_exact<E>(*this).bbox().pmin()[1];
178  }
179 
180  template <typename C, typename E>
181  inline
182  C box_impl_<3, C, E>::max_row() const
183  {
184  return internal::force_exact<E>(*this).bbox().pmax()[1];
185  }
186 
187  template <typename C, typename E>
188  inline
189  unsigned box_impl_<3, C, E>::ncols() const
190  {
191  return internal::force_exact<E>(*this).bbox().len(2);
192  }
193 
194  template <typename C, typename E>
195  inline
196  C box_impl_<3, C, E>::min_col() const
197  {
198  return internal::force_exact<E>(*this).bbox().pmin()[2];
199  }
200 
201  template <typename C, typename E>
202  inline
203  C box_impl_<3, C, E>::max_col() const
204  {
205  return internal::force_exact<E>(*this).bbox().pmax()[2];
206  }
207 
208 
209  template <typename C, typename E>
210  inline
211  unsigned box_impl_<3, C, E>::width() const
212  {
213  return internal::force_exact<E>(*this).bbox().len(2);
214  }
215 
216  template <typename C, typename E>
217  inline
218  unsigned box_impl_<3, C, E>::height() const
219  {
220  return internal::force_exact<E>(*this).bbox().len(1);
221  }
222 
223  template <typename C, typename E>
224  inline
225  unsigned box_impl_<3, C, E>::depth() const
226  {
227  return internal::force_exact<E>(*this).bbox().len(0);
228  }
229 
230 
231  // 2
232 
233  template <typename C, typename E>
234  inline
235  unsigned box_impl_<2, C, E>::nrows() const
236  {
237  return internal::force_exact<E>(*this).bbox().len(0);
238  }
239 
240  template <typename C, typename E>
241  inline
242  C box_impl_<2, C, E>::min_row() const
243  {
244  return internal::force_exact<E>(*this).bbox().pmin()[0];
245  }
246 
247  template <typename C, typename E>
248  inline
249  C box_impl_<2, C, E>::max_row() const
250  {
251  return internal::force_exact<E>(*this).bbox().pmax()[0];
252  }
253 
254  template <typename C, typename E>
255  inline
256  unsigned box_impl_<2, C, E>::ncols() const
257  {
258  return internal::force_exact<E>(*this).bbox().len(1);
259  }
260 
261  template <typename C, typename E>
262  inline
263  C box_impl_<2, C, E>::min_col() const
264  {
265  return internal::force_exact<E>(*this).bbox().pmin()[1];
266  }
267 
268  template <typename C, typename E>
269  inline
270  C box_impl_<2, C, E>::max_col() const
271  {
272  return internal::force_exact<E>(*this).bbox().pmax()[1];
273  }
274 
275  template <typename C, typename E>
276  inline
277  unsigned box_impl_<2, C, E>::width() const
278  {
279  return internal::force_exact<E>(*this).bbox().len(1);
280  }
281 
282  template <typename C, typename E>
283  inline
284  unsigned box_impl_<2, C, E>::height() const
285  {
286  return internal::force_exact<E>(*this).bbox().len(0);
287  }
288 
289  // 1
290 
291  template <typename C, typename E>
292  inline
293  unsigned box_impl_<1, C, E>::ninds() const
294  {
295  return internal::force_exact<E>(*this).bbox().len(0);
296  }
297 
298  template <typename C, typename E>
299  inline
300  C box_impl_<1, C, E>::min_ind() const
301  {
302  return internal::force_exact<E>(*this).bbox().pmin()[0];
303  }
304 
305  template <typename C, typename E>
306  inline
307  C box_impl_<1, C, E>::max_ind() const
308  {
309  return internal::force_exact<E>(*this).bbox().pmax()[0];
310  }
311 
312 # endif // ! MLN_INCLUDE_ONLY
313 
314  } // end of namespace mln::internal
315 
316 } // end of namespace mln
317 
318 
319 #endif // ! MLN_CORE_INTERNAL_BOX_IMPL_HH