---
milena/ChangeLog | 4 +++
milena/mln/core/site_set/box.hh | 51 +++++++++++++++++++++++++++++++++++++++
2 files changed, 55 insertions(+), 0 deletions(-)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index a303bb5..9cca6a5 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,5 +1,9 @@
2013-04-30 Guillaume Lazzara <z(a)lrde.epita.fr>
+ * mln/core/site_set/box.hh: Add shrink() and to_smaller() members.
+
+2013-04-30 Guillaume Lazzara <z(a)lrde.epita.fr>
+
Add a module related to literals.
* doc/mln/literal/literal.dox: New.
diff --git a/milena/mln/core/site_set/box.hh b/milena/mln/core/site_set/box.hh
index aaaa8c3..3f0b71b 100644
--- a/milena/mln/core/site_set/box.hh
+++ b/milena/mln/core/site_set/box.hh
@@ -144,6 +144,15 @@ namespace mln
/// Give a larger box.
box<P> to_larger(unsigned b) const;
+ /// Shrink the box with a border \p b.
+ void shrink(unsigned b);
+
+ /// Shrink the box with a border \p b for dimension \p dim.
+ void shrink(unsigned dim, unsigned b);
+
+ /// Give a smaller box.
+ box<P> to_smaller(unsigned b) const;
+
/// Return the approximated central site of this box.
P pcenter() const;
@@ -359,6 +368,31 @@ namespace mln
template <typename P>
inline
+ void
+ box<P>::shrink(unsigned b)
+ {
+ mln_precondition(is_valid());
+ for (unsigned i = 0; i < P::dim; ++i)
+ {
+ pmin_[i] = static_cast<mln_coord(P)>(pmin_[i] + b);
+ pmax_[i] = static_cast<mln_coord(P)>(pmax_[i] - b);
+ }
+ mln_postcondition(is_valid());
+ }
+
+ template <typename P>
+ inline
+ void
+ box<P>::shrink(unsigned dim, unsigned b)
+ {
+ mln_precondition(is_valid());
+ pmin_[dim] = static_cast<mln_coord(P)>(pmin_[dim] + b);
+ pmax_[dim] = static_cast<mln_coord(P)>(pmax_[dim] - b);
+ mln_postcondition(is_valid());
+ }
+
+ template <typename P>
+ inline
box<P>
larger_than(const box<P> a, const box<P> b)
{
@@ -392,6 +426,23 @@ namespace mln
template <typename P>
inline
+ box<P>
+ box<P>::to_smaller(unsigned b) const
+ {
+ mln_precondition(is_valid());
+ box<P> tmp(*this);
+
+ for (unsigned i = 0; i < P::dim; ++i)
+ {
+ tmp.pmin_[i] = static_cast<mln_coord(P)>(tmp.pmin_[i] + b);
+ tmp.pmax_[i] = static_cast<mln_coord(P)>(tmp.pmax_[i] - b);
+ }
+ mln_postcondition(tmp.is_valid());
+ return tmp;
+ }
+
+ template <typename P>
+ inline
P
box<P>::pcenter() const
{
--
1.7.2.5
Show replies by date