27 #ifndef MLN_CORE_IMAGE_IMAGE1D_HH
28 # define MLN_CORE_IMAGE_IMAGE1D_HH
36 # include <mln/core/internal/fixme.hh>
37 # include <mln/core/internal/image_primary.hh>
38 # include <mln/core/alias/box1d.hh>
40 # include <mln/border/thickness.hh>
41 # include <mln/value/set.hh>
42 # include <mln/fun/i2v/all_to.hh>
55 template <
typename T>
struct image1d;
63 struct data< image1d<T> >
78 void swap_ (
data< image1d<T> >& other_);
79 void reallocate_(
unsigned new_border);
90 struct image_< image1d<T> > : default_image_< T, image1d<T> >
93 typedef trait::image::category::primary category;
94 typedef trait::image::speed::fastest speed;
95 typedef trait::image::size::regular size;
98 typedef trait::image::vw_io::none vw_io;
99 typedef trait::image::vw_set::none vw_set;
100 typedef trait::image::value_access::direct value_access;
101 typedef trait::image::value_storage::one_block value_storage;
102 typedef trait::image::value_browsing::site_wise_only value_browsing;
103 typedef trait::image::value_alignment::with_grid value_alignment;
104 typedef trait::image::value_io::read_write value_io;
107 typedef trait::image::pw_io::read_write pw_io;
108 typedef trait::image::localization::basic_grid localization;
109 typedef trait::image::dimension::one_d dimension;
112 typedef trait::image::ext_domain::extendable ext_domain;
113 typedef trait::image::ext_value::multiple ext_value;
114 typedef trait::image::ext_io::read_write ext_io;
122 template <
typename T>
struct image1d;
133 template <
typename V,
typename T>
134 void from_to_(
const histo::array<V>& from, image1d<T>&
to);
137 template <
typename V,
typename T>
138 void from_to_(
const util::array<V>& from, image1d<T>&
to);
154 template <
typename T>
156 public internal::image_primary< T, box1d, image1d<T> >
158 typedef internal::image_primary< T, mln::box1d, image1d<T> > super_;
178 image1d(
unsigned ninds,
unsigned bdr = border::thickness);
181 image1d(
const box1d& b,
unsigned bdr = border::thickness);
185 void init_(
const box1d& b,
unsigned bdr = border::thickness);
220 unsigned ninds()
const;
227 using super_::index_of_point;
243 const T&
element(
unsigned i)
const;
255 void resize_(
unsigned new_border);
259 template <
typename T,
typename J>
262 # ifndef MLN_INCLUDE_ONLY
265 template <
typename T>
267 void init_(tag::border_t,
unsigned& b,
const image1d<T>& model)
272 template <
typename T,
typename J>
274 void init_(tag::image_t, image1d<T>& target,
const J& model)
277 init_(tag::bbox, b, model);
279 init_(tag::border, bdr, model);
280 target.init_(b, bdr);
288 template <
typename T>
299 template <
typename T>
306 template <
typename T>
313 vb_.pmin() = b_.pmin() - dp;
314 vb_.pmax() = b_.pmax() + dp;
317 template <
typename T>
326 array_ = buffer_ - vb_.pmin().ind();
327 mln_postcondition(vb_.len(0) == b_.len(0) + 2 * bdr_);
330 template <
typename T>
343 template <
typename T>
355 template <
typename T>
369 template <
typename T>
375 template <
typename T>
382 template <
typename T>
386 mln_precondition(ninds != 0);
387 init_(make::box1d(ninds), bdr);
390 template <
typename T>
395 mln_precondition(! this->is_valid());
396 this->data_ =
new internal::data< image1d<T> >(b, bdr);
399 template <
typename T>
404 mln_precondition(this->is_valid());
405 return this->data_->b_;
408 template <
typename T>
413 mln_precondition(this->is_valid());
414 return this->data_->b_;
417 template <
typename T>
422 mln_precondition(this->is_valid());
423 return this->data_->vb_;
426 template <
typename T>
431 mln_precondition(this->is_valid());
432 return this->data_->bdr_;
435 template <
typename T>
440 mln_precondition(this->is_valid());
441 return this->data_->vb_.nsites();
444 template <
typename T>
449 mln_precondition(this->is_valid());
450 return this->data_->vb_.has(p);
453 template <
typename T>
458 mln_precondition(this->has(p));
459 return this->data_->array_[p.ind()];
462 template <
typename T>
467 mln_precondition(this->has(p));
468 return this->data_->array_[p.ind()];
471 template <
typename T>
476 mln_precondition(this->has(
point1d(index)));
477 return this->data_->array_[index];
480 template <
typename T>
485 mln_precondition(this->is_valid());
486 return this->data_->b_.len(0);
489 template <
typename T>
494 mln_precondition(this->has(
point1d(index)));
495 return this->data_->array_[index];
499 template <
typename T>
504 mln_precondition(i < nelements());
505 return this->data_->buffer_[i];
508 template <
typename T>
513 mln_precondition(i < nelements());
514 return this->data_->buffer_[i];
517 template <
typename T>
522 mln_precondition(this->is_valid());
523 return this->data_->buffer_;
526 template <
typename T>
531 mln_precondition(this->is_valid());
532 return this->data_->buffer_;
535 template <
typename T>
540 mln_precondition(this->is_valid());
545 template <
typename T>
550 mln_precondition(i < nelements());
553 mln_postcondition(& this->
operator()(p) == this->data_->buffer_ + i);
557 template <
typename T>
562 this->data_->reallocate_(new_border);
565 # endif // ! MLN_INCLUDE_ONLY
571 # include <mln/core/trait/pixter.hh>
572 # include <mln/core/dpoints_pixter.hh>
573 # include <mln/core/pixter1d.hh>
574 # include <mln/core/w_window.hh>
589 template <
typename V,
typename T>
592 from_to_(
const histo::array<V>& from, image1d<T>&
to)
601 for (
unsigned i = 0; i < from.nvalues(); ++i)
606 template <
typename V,
typename T>
609 from_to_(
const util::array<V>& from, image1d<T>& to)
612 for (
unsigned i = 0; i < from.nelements(); ++i)
626 template <
typename T>
627 struct fwd_pixter< image1d<T> >
629 typedef fwd_pixter1d< image1d<T> > ret;
632 template <
typename T>
633 struct fwd_pixter< const image1d<T> >
635 typedef fwd_pixter1d< const image1d<T> > ret;
638 template <
typename T>
639 struct bkd_pixter< image1d<T> >
641 typedef bkd_pixter1d< image1d<T> > ret;
644 template <
typename T>
645 struct bkd_pixter< const image1d<T> >
647 typedef bkd_pixter1d< const image1d<T> > ret;
652 template <
typename T,
typename W>
653 struct fwd_qixter< image1d<T>, W >
655 typedef dpoints_fwd_pixter< image1d<T> > ret;
658 template <
typename T,
typename W>
659 struct fwd_qixter< const image1d<T>, W >
661 typedef dpoints_fwd_pixter< const image1d<T> > ret;
664 template <
typename T,
typename W>
665 struct bkd_qixter< image1d<T>, W >
667 typedef dpoints_bkd_pixter< image1d<T> > ret;
670 template <
typename T,
typename W>
671 struct bkd_qixter< const image1d<T>, W >
673 typedef dpoints_bkd_pixter< const image1d<T> > ret;
678 template <
typename T,
typename W>
679 struct fwd_nixter< image1d<T>, W >
681 typedef dpoints_fwd_pixter< image1d<T> > ret;
684 template <
typename T,
typename W>
685 struct fwd_nixter< const image1d<T>, W >
687 typedef dpoints_fwd_pixter< const image1d<T> > ret;
690 template <
typename T,
typename W>
691 struct bkd_nixter< image1d<T>, W >
693 typedef dpoints_bkd_pixter< image1d<T> > ret;
696 template <
typename T,
typename W>
697 struct bkd_nixter< const image1d<T>, W >
699 typedef dpoints_bkd_pixter< const image1d<T> > ret;
706 # include <mln/make/image.hh>
708 #endif // ! MLN_CORE_IMAGE_IMAGE1D_HH