Milena (Olena)
User documentation 2.0a Id
|
00001 // Copyright (C) 2008, 2009, 2011 EPITA Research and Development 00002 // Laboratory (LRDE) 00003 // 00004 // This file is part of Olena. 00005 // 00006 // Olena is free software: you can redistribute it and/or modify it under 00007 // the terms of the GNU General Public License as published by the Free 00008 // Software Foundation, version 2 of the License. 00009 // 00010 // Olena is distributed in the hope that it will be useful, 00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00013 // General Public License for more details. 00014 // 00015 // You should have received a copy of the GNU General Public License 00016 // along with Olena. If not, see <http://www.gnu.org/licenses/>. 00017 // 00018 // As a special exception, you may use this file as part of a free 00019 // software project without restriction. Specifically, if other files 00020 // instantiate templates or use macros or inline functions from this 00021 // file, or you compile this file and link it with other files to produce 00022 // an executable, this file does not by itself cause the resulting 00023 // executable to be covered by the GNU General Public License. This 00024 // exception does not however invalidate any other reasons why the 00025 // executable file might be covered by the GNU General Public License. 00026 00027 #ifndef MLN_CORE_IMAGE_DMORPH_EXTENDED_HH 00028 # define MLN_CORE_IMAGE_DMORPH_EXTENDED_HH 00029 00037 00038 # include <mln/core/internal/image_domain_morpher.hh> 00039 # include <mln/core/site_set/box.hh> 00040 00041 00042 namespace mln 00043 { 00044 00045 00046 // Forward declaration. 00047 template <typename I> struct extended; 00048 00049 00050 namespace internal 00051 { 00052 00054 template <typename I> 00055 struct data< extended<I> > 00056 { 00057 data(I& ima, const box<mln_site(I)>& b_); 00058 00059 I ima_; 00060 box<mln_site(I)> b_; 00061 }; 00062 00063 } // end of namespace mln::internal 00064 00065 00066 00067 namespace trait 00068 { 00069 00070 template <typename I> 00071 struct image_< extended<I> > : default_image_morpher< I, 00072 mln_value(I), 00073 extended<I> > 00074 { 00075 typedef trait::image::category::domain_morpher category; 00076 00077 typedef trait::image::ext_domain::none ext_domain; 00078 typedef trait::image::ext_value::irrelevant ext_value; 00079 typedef trait::image::ext_io::irrelevant ext_io; 00080 00081 typedef trait::image::value_storage::disrupted value_storage; 00082 }; 00083 00084 } // end of namespace mln::trait 00085 00086 00087 00091 // 00092 template <typename I> 00093 struct extended : public internal::image_domain_morpher< I, 00094 box<mln_site(I)>, 00095 extended<I> >, 00096 private mlc_not_equal(mln_trait_image_ext_domain(I), 00097 trait::image::ext_domain::none)::check_t 00098 { 00100 typedef mln_value(I) value; 00101 00103 typedef tag::image_<I> skeleton; // This property is lost! 00104 00106 extended(); 00107 00109 extended(I& ima, const box<mln_site(I)>& b); 00110 00112 void init_(I& ima, const box<mln_site(I)>& b); 00113 00115 const box<mln_site(I)>& domain() const; 00116 }; 00117 00118 00119 00120 template <typename I, typename J> 00121 void init_(tag::image_t, extended<I>& target, const J& model); 00122 00123 00124 template <typename I, typename B> 00125 extended<const I> 00126 extended_to(const Image<I>& ima, const Box<B>& b); 00127 00128 template <typename I, typename B> 00129 extended<I> 00130 extended_to(Image<I>& ima, const Box<B>& b); 00131 00132 00133 00134 # ifndef MLN_INCLUDE_ONLY 00135 00136 // init_ 00137 00138 template <typename I, typename J> 00139 inline 00140 void init_(tag::image_t, extended<I>& target, const J& model) 00141 { 00142 I ima; 00143 init_(tag::image, ima, model); 00144 box<mln_site(I)> b; 00145 init_(tag::bbox, b, model); 00146 target.init_(ima, b); 00147 } 00148 00149 00150 // internal::data< extended<I> > 00151 00152 namespace internal 00153 { 00154 00155 template <typename I> 00156 inline 00157 data< extended<I> >::data(I& ima, const box<mln_site(I)>& b) 00158 : ima_(ima), 00159 b_(b) 00160 { 00161 } 00162 00163 } // end of namespace mln::internal 00164 00165 00166 // extended<I> 00167 00168 template <typename I> 00169 inline 00170 extended<I>::extended() 00171 { 00172 } 00173 00174 template <typename I> 00175 inline 00176 extended<I>::extended(I& ima, const box<mln_site(I)>& b) 00177 { 00178 init_(ima, b); 00179 } 00180 00181 template <typename I> 00182 inline 00183 void 00184 extended<I>::init_(I& ima, const box<mln_site(I)>& b) 00185 { 00186 mln_precondition(! this->is_valid()); 00187 this->data_ = new internal::data< extended<I> >(ima, b); 00188 } 00189 00190 template <typename I> 00191 inline 00192 const box<mln_site(I)>& 00193 extended<I>::domain() const 00194 { 00195 return this->data_->b_; 00196 } 00197 00198 00199 // extended_to 00200 00201 template <typename I, typename B> 00202 extended<const I> 00203 extended_to(const Image<I>& ima, const Box<B>& b) 00204 { 00205 mlc_not_equal(mln_trait_image_ext_domain(I), 00206 trait::image::ext_domain::none)::check(); 00207 mln_precondition(exact(ima).is_valid()); 00208 extended<const I> tmp(exact(ima), exact(b)); 00209 return tmp; 00210 } 00211 00212 template <typename I, typename B> 00213 extended<I> 00214 extended_to(Image<I>& ima, const Box<B>& b) 00215 { 00216 mlc_not_equal(mln_trait_image_ext_domain(I), 00217 trait::image::ext_domain::none)::check(); 00218 mln_precondition(exact(ima).is_valid()); 00219 extended<I> tmp(exact(ima), exact(b)); 00220 return tmp; 00221 } 00222 00223 # endif // ! MLN_INCLUDE_ONLY 00224 00225 } // end of namespace mln 00226 00227 00228 #endif // ! MLN_CORE_IMAGE_DMORPH_EXTENDED_HH