Milena (Olena)
User documentation 2.0a Id
|
00001 // Copyright (C) 2007, 2008, 2009 EPITA Research and Development Laboratory (LRDE) 00002 // 00003 // This file is part of Olena. 00004 // 00005 // Olena is free software: you can redistribute it and/or modify it under 00006 // the terms of the GNU General Public License as published by the Free 00007 // Software Foundation, version 2 of the License. 00008 // 00009 // Olena is distributed in the hope that it will be useful, 00010 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00012 // General Public License for more details. 00013 // 00014 // You should have received a copy of the GNU General Public License 00015 // along with Olena. If not, see <http://www.gnu.org/licenses/>. 00016 // 00017 // As a special exception, you may use this file as part of a free 00018 // software project without restriction. Specifically, if other files 00019 // instantiate templates or use macros or inline functions from this 00020 // file, or you compile this file and link it with other files to produce 00021 // an executable, this file does not by itself cause the resulting 00022 // executable to be covered by the GNU General Public License. This 00023 // exception does not however invalidate any other reasons why the 00024 // executable file might be covered by the GNU General Public License. 00025 00026 #ifndef MLN_DATA_PASTE_HH 00027 # define MLN_DATA_PASTE_HH 00028 00032 00033 # include <mln/core/concept/image.hh> 00034 00035 // Specializations are in: 00036 # include <mln/data/paste.spe.hh> 00037 00038 00039 00040 namespace mln 00041 { 00042 00043 namespace data 00044 { 00045 00062 template <typename I, typename J> 00063 void paste(const Image<I>& input, Image<J>& output); 00064 00065 00066 00067 # ifndef MLN_INCLUDE_ONLY 00068 00069 namespace internal 00070 { 00071 00077 // 00078 template <typename I, typename J> 00079 inline 00080 void paste_tests(const Image<I>& input, Image<J>& output) 00081 { 00082 mlc_is(mln_trait_image_pw_io(J), trait::image::pw_io::read_write):: 00083 check(); 00084 mlc_converts_to(mln_value(I), mln_value(J))::check(); 00085 00086 mln_precondition(exact(input).is_valid()); 00087 mln_precondition(exact(input).domain() <= exact(output).domain()); 00088 00089 // Avoid warning when compiling with NDEBUG 00090 (void)input; 00091 (void)output; 00092 } 00093 00094 } // end of namespace mln::data::internal 00095 00096 00097 namespace impl 00098 { 00099 00100 namespace generic 00101 { 00102 00108 // 00109 template <typename I, typename J> 00110 inline 00111 void paste(const Image<I>& input_, Image<J>& output_) 00112 { 00113 trace::entering("data::impl::generic::paste"); 00114 00115 data::internal::paste_tests(input_, output_); 00116 00117 const I& input = exact(input_); 00118 J& output = exact(output_); 00119 00120 00121 mln_piter(I) p(input.domain()); 00122 for_all(p) 00123 output(p) = static_cast<mln_value(J)>(input(p)); 00124 00125 trace::exiting("data::impl::generic::paste"); 00126 } 00127 00128 } // end of namespace mln::data::impl::generic 00129 00130 } // end of namespace mln::data::impl 00131 00132 00133 // Facade. 00134 00135 template <typename I, typename J> 00136 inline 00137 void paste(const Image<I>& input, Image<J>& output) 00138 { 00139 trace::entering("data::paste"); 00140 00141 mlc_converts_to(mln_value(I), mln_value(J))::check(); 00142 00143 internal::paste_tests(input, output); 00144 internal::paste_dispatch(input, output); 00145 00146 trace::exiting("data::paste"); 00147 } 00148 00149 # endif // ! MLN_INCLUDE_ONLY 00150 00151 } // end of namespace mln::data 00152 00153 } // end of namespace mln 00154 00155 00156 00157 #endif // ! MLN_DATA_PASTE_HH