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