
* mln/core/site_set/box.hh: - Add a new version of enlarge() which can be applied on a single dimension passed as parameter. - Add center() which returns an approximated central site of a bo --- milena/ChangeLog | 9 +++++++++ milena/mln/core/site_set/box.hh | 30 ++++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+), 0 deletions(-) diff --git a/milena/ChangeLog b/milena/ChangeLog index 1a947ad..2649954 100644 --- a/milena/ChangeLog +++ b/milena/ChangeLog @@ -1,5 +1,14 @@ 2008-10-27 Guillaume Lazzara <z@lrde.epita.fr> + Add box::center() and a new overload of box::enlarge(). + + * mln/core/site_set/box.hh: + - Add a new version of enlarge() which can be applied on a single + dimension passed as parameter. + - Add center() which returns an approximated central site of a box. + +2008-10-27 Guillaume Lazzara <z@lrde.epita.fr> + Fix wrong or missing traces. * milena/mln/level/fill_with_image.spe.hh, * milena/mln/morpho/erosion.spe.hh: diff --git a/milena/mln/core/site_set/box.hh b/milena/mln/core/site_set/box.hh index 9e8c6db..9a03897 100644 --- a/milena/mln/core/site_set/box.hh +++ b/milena/mln/core/site_set/box.hh @@ -137,9 +137,16 @@ namespace mln /// Enlarge the box with a border \p b. void enlarge(unsigned b); + /// Enlarge the box with a border \p b for dimension \p dim. + void enlarge(unsigned dim, unsigned b); + /// Give a larger box. box<P> to_larger(unsigned b) const; + /// Return the approximated central site of this box. + /// FIXME: Do we want a routine as well like geom::bbox()? + P center() const; + /// Test that the box owns valid data, i.e., is initialized and /// with pmin being 'less-than' pmax. bool is_valid() const; @@ -296,6 +303,17 @@ namespace mln template <typename P> inline + void + box<P>::enlarge(unsigned dim, unsigned b) + { + mln_precondition(is_valid()); + pmin_[dim] -= b; + pmax_[dim] += b; + mln_postcondition(is_valid()); + } + + template <typename P> + inline box<P> larger_than(const box<P> a, const box<P> b) { @@ -329,6 +347,18 @@ namespace mln template <typename P> inline + P + box<P>::center() const + { + mln_precondition(is_valid()); + point2d center; + for (unsigned i = 0; i < P::dim; ++i) + center[i] = pmin_[i] + ((pmax_[i] - pmin_[i]) / 2); + return center; + } + + template <typename P> + inline std::size_t box<P>::memory_size() const { -- 1.5.6.5