00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
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
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 }
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 }
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;
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
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
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 }
00164
00165
00166
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
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 }
00226
00227
00228 #endif // ! MLN_CORE_IMAGE_DMORPH_EXTENDED_HH