$extrastylesheet
Olena  User documentation 2.1
An Image Processing Platform
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
extend.hh
1 // Copyright (C) 2008, 2009, 2010 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_ROUTINE_EXTEND_HH
28 # define MLN_CORE_ROUTINE_EXTEND_HH
29 
37 
38 # include <mln/core/image/dmorph/extension_ima.hh>
39 # include <mln/core/image/dmorph/extension_fun.hh>
40 # include <mln/core/image/dmorph/extension_val.hh>
41 
42 # include <mln/trait/undef.hh>
43 
44 
45 # define mln_extension_type(I,J) \
46  typename mln::internal::extension_type<I,J>::result;
47 
48 # define mln_extension_type_(I,J) \
49  mln::internal::extension_type<I,J>::result;
50 
51 
52 namespace mln
53 {
54 
55  namespace internal
56  {
57 
58  template <typename I, typename J, typename B1, typename B2>
60  {
62  };
63 
64 
65  template <typename I, typename J>
67  metal::bool_<false>, metal::bool_<false> >
68  : mlc_converts_to(J, mln_value(I))::check_t
69  {
71  };
72 
73 
74  template <typename I, typename J>
76  metal::bool_<false>, metal::bool_<true> >
77  {
79  };
80 
81 
82  template <typename I, typename J>
84  metal::bool_<true>, metal::bool_<false> >
85  {
87  };
88 
89 
90  template <typename I, typename J>
93  typename mlc_is_a(J,Image)::eval,
94  typename mlc_is_a(J,Function)::eval>
95  {
96  };
97 
98 
99  } // end of namespace mln::internal
100 
101 
103 
104  template <typename I, typename F>
106  extend(const Image<I>& ima, const Function_v2v<F>& fun);
107 
108  template <typename I, typename F>
110  extend(Image<I>& ima, const Function_v2v<F>& fun);
111 
112 
114 
115  template <typename I, typename J>
117  extend(const Image<I>& ima, const Image<J>& ext);
118 
119 
121 
122  template <typename I>
124  extend(const Image<I>& ima, const mln_value(I)& val);
125 
126  template <typename I>
128  extend(Image<I>& ima, const mln_value(I)& val);
129 
130 
131 
132 # ifndef MLN_INCLUDE_ONLY
133 
134 
135  // With a function.
136 
137  template <typename I, typename F>
138  inline
140  extend(const Image<I>& ima, const Function_v2v<F>& fun)
141  {
142  mlc_converts_to(mln_result(F), mln_value(I))::check();
143  extension_fun<const I, F> tmp(exact(ima), exact(fun));
144  return tmp;
145  }
146 
147  template <typename I, typename F>
148  inline
149  extension_fun<I, F>
150  extend(Image<I>& ima, const Function_v2v<F>& fun)
151  {
152  mlc_converts_to(mln_result(F), mln_value(I))::check();
153  extension_fun<I, F> tmp(exact(ima), exact(fun));
154  return tmp;
155  }
156 
157 
158  // With an image.
159 
160  template <typename I, typename J>
161  extension_ima<const I, const J>
162  extend(const Image<I>& ima, const Image<J>& ext)
163  {
164  mlc_converts_to(mln_value(J), mln_value(I))::check();
165  extension_ima<const I, const J> tmp(exact(ima), exact(ext));
166  return tmp;
167  }
168 
169 
170  // With a value.
171 
172  template <typename I>
173  inline
174  extension_val<const I>
175  extend(const Image<I>& ima, const mln_value(I)& val)
176  {
177  extension_val<const I> tmp(exact(ima), val);
178  return tmp;
179  }
180 
181  template <typename I>
182  inline
183  extension_val<I>
184  extend(Image<I>& ima, const mln_value(I)& val)
185  {
186  extension_val<I> tmp(exact(ima), val);
187  return tmp;
188  }
189 
190 
191 # endif // ! MLN_INCLUDE_ONLY
192 
193 } // end of namespace mln
194 
195 
196 #endif // ! MLN_CORE_ROUTINE_EXTEND_HH