27 #ifndef MLN_MORPHO_ATTRIBUTE_VOLUME_HH
28 # define MLN_MORPHO_ATTRIBUTE_VOLUME_HH
35 # include <mln/accu/internal/base.hh>
36 # include <mln/math/diff_abs.hh>
37 # include <mln/util/pix.hh>
46 template <
typename I>
struct volume;
57 struct accumulator_< morpho::attribute::volume<I> >
59 typedef accumulator::has_untake::no has_untake;
60 typedef accumulator::has_set_value::no has_set_value;
61 typedef accumulator::has_stop::no has_stop;
62 typedef accumulator::when_pix::use_v when_pix;
80 :
public mln::accu::internal::base< unsigned , volume<I> >
82 typedef mln_value(I) argument;
90 void take(
const mln_value(I)& v);
94 void take_as_init_(
const mln_value(I)& v);
106 unsigned area()
const;
110 mln_value(I) cur_level_;
119 # ifndef MLN_INCLUDE_ONLY
121 template <
typename I>
128 template <
typename I>
136 template <
typename I>
141 mln_invariant(volume_ != mln_max(
unsigned));
148 volume_ += 1 + math::diff_abs(v, cur_level_);
152 template <
typename I>
157 mln_invariant(volume_ != mln_max(
unsigned));
161 template <
typename I>
164 volume<I>::take(
const volume<I>& other)
166 mln_invariant(volume_ != mln_max(
unsigned));
167 area_ += other.area_;
170 other.area_ * math::diff_abs(other.cur_level_, cur_level_);
174 template <
typename I>
177 volume<I>::take_as_init_(
const mln_value(I)& v)
184 template <
typename I>
187 volume<I>::take_as_init_(
const util::pix<I>& px)
189 take_as_init_(px.v());
192 template <
typename I>
200 template <
typename I>
208 template <
typename I>
216 # endif // ! MLN_INCLUDE_ONLY
225 #endif // ! MLN_MORPHO_ATTRIBUTE_VOLUME_HH