$extrastylesheet
Olena  User documentation 2.1
An Image Processing Platform
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
paste.hh
1 // Copyright (C) 2007, 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_DATA_PASTE_HH
28 # define MLN_DATA_PASTE_HH
29 
33 
34 # include <mln/core/concept/image.hh>
35 
36 // Specializations are in:
37 # include <mln/data/paste.spe.hh>
38 
39 
40 
41 namespace mln
42 {
43 
44  namespace data
45  {
46 
65  template <typename I, typename J>
66  void paste(const Image<I>& input, Image<J>& output);
67 
68 
69 
70 # ifndef MLN_INCLUDE_ONLY
71 
72  namespace internal
73  {
74 
80  //
81  template <typename I, typename J>
82  inline
83  void paste_tests(const Image<I>& input, Image<J>& output)
84  {
85  mlc_is(mln_trait_image_pw_io(J), trait::image::pw_io::read_write)::
86  check();
87  mlc_converts_to(mln_value(I), mln_value(J))::check();
88 
89  mln_precondition(exact(input).is_valid());
90  mln_precondition(exact(input).domain() <= exact(output).domain());
91 
92  // Avoid warning when compiling with NDEBUG
93  (void)input;
94  (void)output;
95  }
96 
97  } // end of namespace mln::data::internal
98 
99 
100  namespace impl
101  {
102 
103  namespace generic
104  {
105 
111  //
112  template <typename I, typename J>
113  inline
114  void paste(const Image<I>& input_, Image<J>& output_)
115  {
116  mln_trace("data::impl::generic::paste");
117 
118  data::internal::paste_tests(input_, output_);
119 
120  const I& input = exact(input_);
121  J& output = exact(output_);
122 
123 
124  mln_piter(I) p(input.domain());
125  for_all(p)
126  output(p) = static_cast<mln_value(J)>(input(p));
127 
128  }
129 
130  } // end of namespace mln::data::impl::generic
131 
132  } // end of namespace mln::data::impl
133 
134 
135  // Facade.
136 
137  template <typename I, typename J>
138  inline
139  void paste(const Image<I>& input, Image<J>& output)
140  {
141  mln_trace("data::paste");
142 
143  mlc_converts_to(mln_value(I), mln_value(J))::check();
144 
145  internal::paste_tests(input, output);
146  internal::paste_dispatch(input, output);
147 
148  }
149 
150 # endif // ! MLN_INCLUDE_ONLY
151 
152  } // end of namespace mln::data
153 
154 } // end of namespace mln
155 
156 
157 
158 #endif // ! MLN_DATA_PASTE_HH