27 #ifndef MLN_MORPHO_ATTRIBUTE_HEIGHT_HH
28 # define MLN_MORPHO_ATTRIBUTE_HEIGHT_HH
34 # include <mln/accu/internal/base.hh>
36 # include <mln/util/pix.hh>
37 # include <mln/math/diff_abs.hh>
38 # include <mln/math/min.hh>
39 # include <mln/math/max.hh>
48 template <
typename I>
struct height;
59 struct accumulator_< morpho::attribute::height<I> >
61 typedef accumulator::has_untake::no has_untake;
62 typedef accumulator::has_set_value::no has_set_value;
63 typedef accumulator::has_stop::no has_stop;
64 typedef accumulator::when_pix::use_v when_pix;
82 :
public mln::accu::internal::base< unsigned , height<I> >
84 typedef mln_value(I) argument;
91 void take(
const mln_value(I)& v);
94 void take_as_init_(
const mln_value(I)& v);
107 unsigned current_level()
const;
120 # ifndef MLN_INCLUDE_ONLY
122 template <
typename I>
125 : initialized_ (false)
129 template <
typename I>
137 template <
typename I>
149 template <
typename I>
157 template <
typename I>
160 height<I>::take(
const height<I>& other)
162 mln_invariant(((ref_ <= cur_) && (other.ref_ <= other.cur_))
163 || ((ref_ >= cur_) && (other.ref_ >= other.cur_)));
170 else if (ref_ < cur_)
173 ref_ = math::min(ref_, other.ref_);
174 cur_ = math::max(cur_, other.cur_);
179 ref_ = math::max(ref_, other.ref_);
180 cur_ = math::min(cur_, other.cur_);
184 template <
typename I>
187 height<I>::take_as_init_(
const mln_value(I)& v)
193 template <
typename I>
196 height<I>::take_as_init_(
const util::pix<I>& px)
198 take_as_init_(px.v());
202 template <
typename I>
207 mln_invariant(is_valid());
209 return math::diff_abs(ref_, cur_);
212 template <
typename I>
220 template <
typename I>
229 template <
typename I>
237 # endif // ! MLN_INCLUDE_ONLY
246 #endif // ! MLN_MORPHO_ATTRIBUTE_HEIGHT_HH