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;
66 struct data< image1d<
T> >
68 data(
const box1d& b,
unsigned bdr);
81 void swap_ (
data< image1d<T> >& other_);
82 void reallocate_(
unsigned new_border);
93 struct image_< image1d<
T> > : default_image_< T, image1d<T> >
96 typedef trait::image::category::primary
category;
97 typedef trait::image::speed::fastest
speed;
98 typedef trait::image::size::regular
size;
101 typedef trait::image::vw_io::none
vw_io;
102 typedef trait::image::vw_set::none
vw_set;
103 typedef trait::image::value_access::direct
value_access;
104 typedef trait::image::value_storage::one_block
value_storage;
105 typedef trait::image::value_browsing::site_wise_only
value_browsing;
107 typedef trait::image::value_io::read_write
value_io;
110 typedef trait::image::pw_io::read_write
pw_io;
111 typedef trait::image::localization::basic_grid
localization;
112 typedef trait::image::dimension::one_d
dimension;
115 typedef trait::image::ext_domain::extendable
ext_domain;
116 typedef trait::image::ext_value::multiple
ext_value;
117 typedef trait::image::ext_io::read_write
ext_io;
125 template <
typename T>
struct image1d;
136 template <
typename T>
206 unsigned ninds()
const;
214 using super_::offset_of_point;
242 void resize_(
unsigned new_border);
247 template <
typename T,
typename J>
250 # ifndef MLN_INCLUDE_ONLY
253 template <
typename T>
260 template <
typename T,
typename J>
262 void init_(tag::image_t, image1d<T>& target,
const J& model)
268 target.init_(b, bdr);
276 template <
typename T>
287 template <
typename T>
294 template <
typename T>
301 vb_.pmin() = b_.pmin() -
dp;
302 vb_.pmax() = b_.pmax() +
dp;
305 template <
typename T>
314 array_ = buffer_ - vb_.pmin().ind();
315 mln_postcondition(vb_.len(0) == b_.len(0) + 2 * bdr_);
318 template <
typename T>
331 template <
typename T>
343 template <
typename T>
357 template <
typename T>
359 image1d<T>::image1d()
363 template <
typename T>
365 image1d<T>::image1d(
const box1d& b,
unsigned bdr)
370 template <
typename T>
372 image1d<T>::image1d(
unsigned ninds,
unsigned bdr)
374 mln_precondition(ninds != 0);
375 init_(make::box1d(ninds), bdr);
378 template <
typename T>
381 image1d<T>::init_(
const box1d& b,
unsigned bdr)
383 mln_precondition(! this->is_valid());
384 this->data_ =
new internal::data< image1d<T> >(b, bdr);
387 template <
typename T>
390 image1d<T>::domain()
const
392 mln_precondition(this->is_valid());
393 return this->data_->b_;
396 template <
typename T>
401 mln_precondition(this->is_valid());
402 return this->data_->b_;
405 template <
typename T>
408 image1d<T>::vbbox()
const
410 mln_precondition(this->is_valid());
411 return this->data_->vb_;
414 template <
typename T>
417 image1d<T>::border()
const
419 mln_precondition(this->is_valid());
420 return this->data_->bdr_;
423 template <
typename T>
426 image1d<T>::nelements()
const
428 mln_precondition(this->is_valid());
429 return this->data_->vb_.nsites();
432 template <
typename T>
435 image1d<T>::has(
const point1d& p)
const
437 mln_precondition(this->is_valid());
438 return this->data_->vb_.has(p);
441 template <
typename T>
444 image1d<T>::operator()(
const point1d& p)
const
446 mln_precondition(this->
has(p));
447 return this->data_->array_[p.ind()];
450 template <
typename T>
453 image1d<T>::operator()(
const point1d& p)
455 mln_precondition(this->
has(p));
456 return this->data_->array_[p.ind()];
459 template <
typename T>
462 image1d<T>::at_(def::coord offset)
const
465 return this->data_->array_[offset];
468 template <
typename T>
473 mln_precondition(this->is_valid());
474 return this->data_->b_.len(0);
477 template <
typename T>
480 image1d<T>::at_(def::coord offset)
483 return this->data_->array_[offset];
487 template <
typename T>
490 image1d<T>::element(
unsigned i)
const
493 return this->data_->buffer_[i];
496 template <
typename T>
499 image1d<T>::element(
unsigned i)
502 return this->data_->buffer_[i];
505 template <
typename T>
508 image1d<T>::buffer()
const
510 mln_precondition(this->is_valid());
511 return this->data_->buffer_;
514 template <
typename T>
519 mln_precondition(this->is_valid());
520 return this->data_->buffer_;
523 template <
typename T>
526 image1d<T>::delta_offset(
const dpoint1d& dp)
const
528 mln_precondition(this->is_valid());
533 template <
typename T>
536 image1d<T>::point_at_offset(
unsigned i)
const
539 def::coord ind =
static_cast<def::coord
>(i + this->data_->vb_.min_ind());
541 mln_postcondition(& this->
operator()(p) == this->data_->buffer_ + i);
545 template <
typename T>
548 image1d<T>::resize_(
unsigned new_border)
550 this->data_->reallocate_(new_border);
553 # endif // ! MLN_INCLUDE_ONLY
559 # include <mln/core/trait/pixter.hh>
560 # include <mln/core/dpoints_pixter.hh>
561 # include <mln/core/pixter1d.hh>
562 # include <mln/core/w_window.hh>
574 template <
typename T>
580 template <
typename T>
586 template <
typename T>
592 template <
typename T>
593 struct bkd_pixter< const
image1d<
T> >
600 template <
typename T,
typename W>
606 template <
typename T,
typename W>
612 template <
typename T,
typename W>
618 template <
typename T,
typename W>
619 struct bkd_qixter< const
image1d<
T>, W >
626 template <
typename T,
typename W>
632 template <
typename T,
typename W>
638 template <
typename T,
typename W>
644 template <
typename T,
typename W>
645 struct bkd_nixter< const
image1d<
T>, W >
654 # include <mln/make/image.hh>
656 #endif // ! MLN_CORE_IMAGE_IMAGE1D_HH