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 #ifndef MLN_CORE_IMAGE_DMORPH_EXTENDED_HH
00027 # define MLN_CORE_IMAGE_DMORPH_EXTENDED_HH
00028
00036
00037 # include <mln/core/internal/image_domain_morpher.hh>
00038 # include <mln/core/site_set/box.hh>
00039
00040
00041 namespace mln
00042 {
00043
00044
00045
00046 template <typename I> class extended;
00047
00048
00049 namespace internal
00050 {
00051
00053 template <typename I>
00054 struct data< extended<I> >
00055 {
00056 data(I& ima, const box<mln_site(I)>& b_);
00057
00058 I ima_;
00059 box<mln_site(I)> b_;
00060 };
00061
00062 }
00063
00064
00065
00066 namespace trait
00067 {
00068
00069 template <typename I>
00070 struct image_< extended<I> > : default_image_morpher< I,
00071 mln_value(I),
00072 extended<I> >
00073 {
00074 typedef trait::image::category::domain_morpher category;
00075
00076 typedef trait::image::ext_domain::none ext_domain;
00077 typedef trait::image::ext_value::irrelevant ext_value;
00078 typedef trait::image::ext_io::irrelevant ext_io;
00079
00080 typedef trait::image::value_storage::disrupted value_storage;
00081 };
00082
00083 }
00084
00085
00086
00090
00091 template <typename I>
00092 struct extended : public internal::image_domain_morpher< I,
00093 box<mln_site(I)>,
00094 extended<I> >,
00095 private mlc_not_equal(mln_trait_image_ext_domain(I),
00096 trait::image::ext_domain::none)::check_t
00097 {
00099 typedef mln_value(I) value;
00100
00102 typedef tag::image_<I> skeleton;
00103
00105 extended();
00106
00108 extended(I& ima, const box<mln_site(I)>& b);
00109
00111 void init_(I& ima, const box<mln_site(I)>& b);
00112
00114 const box<mln_site(I)>& domain() const;
00115 };
00116
00117
00118
00119 template <typename I, typename J>
00120 void init_(tag::image_t, extended<I>& target, const J& model);
00121
00122
00123 template <typename I, typename B>
00124 extended<const I>
00125 extended_to(const Image<I>& ima, const Box<B>& b);
00126
00127 template <typename I, typename B>
00128 extended<I>
00129 extended_to(Image<I>& ima, const Box<B>& b);
00130
00131
00132
00133 # ifndef MLN_INCLUDE_ONLY
00134
00135
00136
00137 template <typename I, typename J>
00138 inline
00139 void init_(tag::image_t, extended<I>& target, const J& model)
00140 {
00141 I ima;
00142 init_(tag::image, ima, model);
00143 box<mln_site(I)> b;
00144 init_(tag::bbox, b, model);
00145 target.init_(ima, b);
00146 }
00147
00148
00149
00150
00151 namespace internal
00152 {
00153
00154 template <typename I>
00155 inline
00156 data< extended<I> >::data(I& ima, const box<mln_site(I)>& b)
00157 : ima_(ima),
00158 b_(b)
00159 {
00160 }
00161
00162 }
00163
00164
00165
00166
00167 template <typename I>
00168 inline
00169 extended<I>::extended()
00170 {
00171 }
00172
00173 template <typename I>
00174 inline
00175 extended<I>::extended(I& ima, const box<mln_site(I)>& b)
00176 {
00177 init_(ima, b);
00178 }
00179
00180 template <typename I>
00181 inline
00182 void
00183 extended<I>::init_(I& ima, const box<mln_site(I)>& b)
00184 {
00185 mln_precondition(! this->is_valid());
00186 this->data_ = new internal::data< extended<I> >(ima, b);
00187 }
00188
00189 template <typename I>
00190 inline
00191 const box<mln_site(I)>&
00192 extended<I>::domain() const
00193 {
00194 return this->data_->b_;
00195 }
00196
00197
00198
00199
00200 template <typename I, typename B>
00201 extended<const I>
00202 extended_to(const Image<I>& ima, const Box<B>& b)
00203 {
00204 mlc_not_equal(mln_trait_image_ext_domain(I),
00205 trait::image::ext_domain::none)::check();
00206 mln_precondition(exact(ima).is_valid());
00207 extended<const I> tmp(exact(ima), exact(b));
00208 return tmp;
00209 }
00210
00211 template <typename I, typename B>
00212 extended<I>
00213 extended_to(Image<I>& ima, const Box<B>& b)
00214 {
00215 mlc_not_equal(mln_trait_image_ext_domain(I),
00216 trait::image::ext_domain::none)::check();
00217 mln_precondition(exact(ima).is_valid());
00218 extended<I> tmp(exact(ima), exact(b));
00219 return tmp;
00220 }
00221
00222 # endif // ! MLN_INCLUDE_ONLY
00223
00224 }
00225
00226
00227 #endif // ! MLN_CORE_IMAGE_DMORPH_EXTENDED_HH