27 #ifndef MLN_CORE_IMAGE_COMPLEX_IMAGE_HH
28 # define MLN_CORE_IMAGE_COMPLEX_IMAGE_HH
36 # include <mln/trait/images.hh>
38 # include <mln/core/internal/image_primary.hh>
39 # include <mln/metal/vec.hh>
40 # include <mln/core/site_set/p_complex.hh>
41 # include <mln/core/site_set/complex_psite.hh>
42 # include <mln/value/set.hh>
47 # define mlc_unbool(V) \
48 typename mln::internal::unbool<V>::ret
67 operator bool&() {
return b_; }
68 operator const bool&()
const {
return b_; }
78 template <
typename V>
struct unbool {
typedef V
ret; };
96 template <
unsigned D,
typename G,
typename V>
class complex_image;
104 template <
unsigned D,
typename G,
typename V>
105 struct data< complex_image<D, G, V> >
107 data(
const p_complex<D, G>& pc,
108 const metal::vec< D + 1, std::vector<V> >& values);
110 metal::vec< D + 1, std::vector< mlc_unbool(V) > > values_;
111 const p_complex<D, G> pc_;
120 template <
unsigned D,
typename G,
typename V>
121 struct image_< complex_image<D, G, V> >
122 : default_image_< V, complex_image<D, G, V> >
124 typedef trait::image::category::primary
category;
127 typedef trait::image::speed::fast
speed;
128 typedef trait::image::size::regular
size;
131 typedef trait::image::value_access::direct
value_access;
135 typedef trait::image::vw_io::none
vw_io;
136 typedef trait::image::vw_set::none
vw_set;
137 typedef trait::image::value_storage::disrupted
value_storage;
138 typedef trait::image::value_browsing::site_wise_only
value_browsing;
140 typedef trait::image::value_io::read_write
value_io;
143 typedef trait::image::pw_io::read_write
pw_io;
149 typedef typename trait::image::dimension::none
dimension;
152 typedef trait::image::ext_domain::none
ext_domain;
153 typedef trait::image::ext_value::irrelevant
ext_value;
154 typedef trait::image::ext_io::irrelevant
ext_io;
169 template <
unsigned D,
typename G,
typename V>
172 complex_image<D, G, V> >
176 static const unsigned dim = D;
197 const metal::vec< D + 1, std::vector<V> >&
values);
203 const metal::vec< D + 1, std::vector<V> >&
values);
217 const metal::vec<D + 1, std::vector< mlc_unbool(V) > >&
values()
const;
223 template <
unsigned D,
typename G,
typename V,
typename W>
224 void init_(tag::image_t,
229 # ifndef MLN_INCLUDE_ONLY
235 template <
unsigned D,
typename G,
typename V,
typename W>
237 void init_(tag::image_t,
241 metal::vec<D + 1, std::vector<V> > values;
242 for (
unsigned i = 0; i <= D; ++i)
253 template <
unsigned D,
typename G,
typename V>
256 const metal::vec< D + 1, std::vector<V> >& values)
261 for (
unsigned i = 0; i <= D; ++i)
263 values_[i].reserve(values[i].size());
264 values_[i].insert(values_[i].begin(),
265 values[i].begin(), values[i].end());
272 for (
unsigned i = 0; i < D; ++i)
273 mln_precondition(pc.nfaces_of_dim(i) == values[i].size());
283 template <
unsigned D,
typename G,
typename V>
285 complex_image<D, G, V>::complex_image()
289 template <
unsigned D,
typename G,
typename V>
291 complex_image<D, G, V>::complex_image(
const p_complex<D, G>& pc)
293 metal::vec<D + 1, std::vector<V> > values;
294 for (
unsigned i = 0; i <= D; ++i)
295 values[i].
resize(pc.nfaces_of_dim(i));
299 template <
unsigned D,
typename G,
typename V>
301 complex_image<D, G, V>::complex_image(
const p_complex<D, G>& pc,
302 const metal::vec< D + 1,
303 std::vector<V> >& values)
308 template <
unsigned D,
typename G,
typename V>
311 complex_image<D, G, V>::init_(
const p_complex<D, G>& pc,
312 const metal::vec< D + 1, std::vector<V> >& values)
314 mln_precondition(! this->is_valid());
316 new internal::data< complex_image<D, G, V> >(pc, values);
323 template <
unsigned D,
typename G,
typename V>
325 typename complex_image<D, G, V>::rvalue
326 complex_image<D, G, V>::operator()(
const complex_psite<D, G>& p)
const
328 mln_precondition(this->data_->pc_.has(p));
329 return this->data_->values_[p.n()][p.face_id()];
332 template <
unsigned D,
typename G,
typename V>
334 typename complex_image<D, G, V>::lvalue
335 complex_image<D, G, V>::operator()(
const complex_psite<D, G>& p)
337 mln_precondition(this->data_->pc_.has(p));
338 return this->data_->values_[p.n()][p.face_id()];
341 template <
unsigned D,
typename G,
typename V>
343 const metal::vec< D + 1, std::vector< mlc_unbool(V) > >&
344 complex_image<D, G, V>::values()
const
346 return this->data_->values_;
349 template <
unsigned D,
typename G,
typename V>
351 const p_complex<D, G>&
352 complex_image<D, G, V>::domain()
const
354 mln_precondition(this->is_valid());
355 return this->data_->pc_;
358 # endif // ! MLN_INCLUDE_ONLY
364 #endif // ! MLN_CORE_IMAGE_COMPLEX_IMAGE_HH