https://svn.lrde.epita.fr/svn/oln/trunk/olena
Index: ChangeLog
from Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
Add torus topology and type of ''image >> fun''.
* oln/core/gen/torus_pset.hh: New.
* oln/core/gen/torus_image.hh: New.
* oln/core/internal/op_image_through_fv2v.hh: New.
* oln/core/concept/dpoint.hh (op_mod_equal_): New.
(check__): Update.
* oln/core/concept/operators.hh (operator%=, operator%): New.
* oln/core/gen/op.hh (through, oln_decl_op_through): New.
* oln/core/internal/dpoint_base.hh (impl_op_mod_equal_, set_all): New.
* oln/core/internal/box.hh (box_fwd_piter_, box_bkd_piter_): Better ctors.
* oln/core/internal/image_ops.hh (operator>>): New.
* oln/core/internal/pset_adaptor.hh (adapted_): New.
* oln/morpho/elementary_erosion.hh (comment): Extend.
* oln/level/local.hh,
* oln/level/apply_local.hh: Cosmetic changes.
core/concept/dpoint.hh | 11 +
core/concept/operators.hh | 21 ++
core/gen/op.hh | 2
core/gen/torus_image.hh | 267 +++++++++++++++++++++++++++++++++
core/gen/torus_pset.hh | 144 +++++++++++++++++
core/internal/box.hh | 16 +
core/internal/dpoint_base.hh | 28 ++-
core/internal/image_ops.hh | 32 +++
core/internal/op_image_through_fv2v.hh | 193 +++++++++++++++++++++++
core/internal/pset_adaptor.hh | 2
level/apply_local.hh | 0
morpho/elementary_erosion.hh | 18 ++
12 files changed, 723 insertions(+), 11 deletions(-)
Index: oln/core/concept/dpoint.hh
--- oln/core/concept/dpoint.hh (revision 935)
+++ oln/core/concept/dpoint.hh (working copy)
@@ -71,6 +71,9 @@
/// Operator -=.
Exact& op_minus_equal_(const Exact& rhs);
+ /// Operator %=.
+ Exact& op_mod_equal_(const Exact& rhs);
+
/// Operator -.
Exact op_unary_minus_() const;
@@ -153,6 +156,12 @@
}
template <typename Exact>
+ Exact& Dpoint<Exact>::op_mod_equal_(const Exact& rhs)
+ {
+ return exact(this)->impl_op_mod_equal_(rhs);
+ }
+
+ template <typename Exact>
Exact Dpoint<Exact>::op_unary_minus_() const
{
return exact(this)->impl_op_unary_minus_();
@@ -181,6 +190,8 @@
impl_op_plus_equal_adr = 0;
Exact& (Exact::*impl_op_minus_equal_adr)(const Exact& rhs) = &
Exact::impl_op_minus_equal_;
impl_op_minus_equal_adr = 0;
+ Exact& (Exact::*impl_op_mod_equal_adr)(const Exact& rhs) = &
Exact::impl_op_mod_equal_;
+ impl_op_mod_equal_adr = 0;
Exact (Exact::*impl_op_unary_minus_adr)() const = & Exact::impl_op_unary_minus_;
impl_op_unary_minus_adr = 0;
}
Index: oln/core/concept/operators.hh
--- oln/core/concept/operators.hh (revision 935)
+++ oln/core/concept/operators.hh (working copy)
@@ -67,6 +67,14 @@
template <typename T>
T operator+ (const Any<T>& lhs, const Any<T>& rhs);
+ /// Operator %= (default version).
+ template <typename L, typename R>
+ L& operator%=(Any<L>& lhs, const Any<R>& rhs);
+
+ /// Operator % (default version).
+ template <typename T>
+ T operator% (const Any<T>& lhs, const Any<T>& rhs);
+
/// Operator -= (default version).
template <typename L, typename R>
L& operator-=(Any<L>& lhs, const Any<R>& rhs);
@@ -129,6 +137,19 @@
}
template <typename L, typename R>
+ L& operator%=(Any<L>& lhs, const Any<R>& rhs)
+ {
+ return exact(lhs).op_mod_equal_(exact(rhs));
+ }
+
+ template <typename T>
+ T operator% (const Any<T>& lhs, const Any<T>& rhs)
+ {
+ T tmp = exact(lhs);
+ return tmp %= exact(rhs);
+ }
+
+ template <typename L, typename R>
L& operator-=(Any<L>& lhs, const Any<R>& rhs)
{
return exact(lhs).op_minus_equal_(exact(rhs));
Index: oln/core/gen/torus_pset.hh
--- oln/core/gen/torus_pset.hh (revision 0)
+++ oln/core/gen/torus_pset.hh (revision 0)
@@ -0,0 +1,144 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef OLN_CORE_GEN_TORUS_PSET_HH
+# define OLN_CORE_GEN_TORUS_PSET_HH
+
+# include <oln/core/internal/pset_adaptor.hh>
+# include <oln/core/concept/dpoint.hh>
+
+
+
+namespace oln
+{
+
+# define current torus_pset<Ps>
+# define super internal::pset_adaptor_< current >
+
+ // Fwd decl.
+ template <typename Ps> class torus_pset;
+
+
+ // Super type.
+ template <typename Ps>
+ struct super_trait_< current >
+ {
+ typedef super ret;
+ };
+
+
+ // Virtual types.
+ template <typename Ps>
+ struct vtypes< current >
+ {
+ typedef Ps adapted;
+ };
+
+
+ /// Generic box class based on a point class.
+
+ template <typename Ps>
+ class torus_pset : public super
+ {
+ public:
+
+ stc_using(point);
+ stc_using(box);
+ typedef oln_dpoint(point) dpoint;
+
+ torus_pset();
+ torus_pset(const Ps& pset);
+ void init_pset(const Ps& pset);
+
+ point relocate(const point& p) const;
+ bool impl_has(const point& p) const;
+
+ private:
+ point pmin_;
+ dpoint size_;
+
+ }; // end of class oln::torus_pset<Ps>
+
+
+ template <typename Ps>
+ std::ostream& operator<<(std::ostream& ostr, const
torus_pset<Ps>& ps)
+ {
+ return ostr << "torus " << ps.adapted_();
+ }
+
+
+# ifndef OLN_INCLUDE_ONLY
+
+ template <typename Ps>
+ current::torus_pset()
+ {
+ mlc::assert_< mlc_is_a(Ps, Point_Set) >::check();
+ }
+
+ template <typename Ps>
+ current::torus_pset(const Ps& pset)
+ : super(pset)
+ {
+ mlc::assert_< mlc_is_a(Ps, Point_Set) >::check();
+ this->pmin_ = pset.pmin();
+ dpoint unit; unit.set_all(1);
+ this->size_ = pset.pmax() - pset.pmin() + unit;
+ }
+
+ template <typename Ps>
+ void
+ current::init_pset(const Ps& pset)
+ {
+ this->ps_ = pset;
+ this->pmin_ = pset.pmin();
+ dpoint unit; unit.set_all(1);
+ this->size_ = pset.pmax() - pset.pmin() + unit;
+ }
+
+ template <typename Ps>
+ typename current::point
+ current::relocate(const typename current::point& p) const
+ {
+ return pmin_ + (p - pmin_) % size_;
+ }
+
+ template <typename Ps>
+ bool
+ current::impl_has(const typename current::point& p) const
+ {
+ return this->ps_.has(relocate(p));
+ }
+
+# endif // ! OLN_INCLUDE_ONLY
+
+# undef super
+# undef current
+
+} // end of namespace oln
+
+
+#endif // ! OLN_CORE_GEN_TORUS_PSET_HH
Index: oln/core/gen/op.hh
--- oln/core/gen/op.hh (revision 935)
+++ oln/core/gen/op.hh (working copy)
@@ -96,6 +96,7 @@
# define oln_decl_op_restricted_to(Lconcept, Rconcept) oln_decl_op_( restricted_to,
Lconcept, |, Rconcept)
# define oln_decl_op_over(Lconcept, Rconcept) oln_decl_op_( over,
Lconcept, /, Rconcept)
# define oln_decl_op_applied_on(Lconcept, Rconcept) oln_decl_op_( applied_on,
Lconcept, <<, Rconcept)
+# define oln_decl_op_through(Lconcept, Rconcept) oln_decl_op_( through,
Lconcept, >>, Rconcept)
// ...
@@ -112,6 +113,7 @@
struct restricted_to;
struct over;
struct applied_on;
+ struct through;
/// \}
Index: oln/core/gen/torus_image.hh
--- oln/core/gen/torus_image.hh (revision 0)
+++ oln/core/gen/torus_image.hh (revision 0)
@@ -0,0 +1,267 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef OLN_CORE_GEN_TORUS_IMAGE_HH
+# define OLN_CORE_GEN_TORUS_IMAGE_HH
+
+# include <oln/core/internal/image_base.hh>
+# include <oln/core/gen/torus_pset.hh>
+# include <oln/core/gen/inplace.hh>
+
+
+
+namespace oln
+{
+
+ // Fwd decl.
+ template <typename I> class torus_image;
+
+
+ /// Virtual types.
+ template <typename I>
+ struct vtypes< torus_image<I> >
+ {
+ typedef I delegatee;
+ typedef behavior::identity behavior;
+
+ typedef torus_pset<oln_pset(I)> pset;
+ typedef internal::pair<I, pset> data;
+
+ typedef oln_possible_lvalue(I) lvalue;
+
+ typedef torus_image< oln_plain(I) > plain;
+ typedef torus_image< pl::rec<I> > skeleton;
+ };
+
+
+ /// Super type.
+ template <typename I>
+ struct super_trait_< torus_image<I> >
+ {
+ typedef torus_image<I> current__;
+ typedef internal::single_image_morpher_<current__> ret;
+ };
+
+
+ /// Class for images defined by a point set and a single value.
+
+ template <typename I>
+ class torus_image : public internal::single_image_morpher_< torus_image<I>
>
+ {
+ typedef torus_image<I> current;
+ typedef internal::single_image_morpher_<current> super;
+ public:
+
+ stc_using(point);
+ stc_using(rvalue);
+ typedef stc_find_type(I, lvalue) lvalue; // FIXME: macro; propagate in similar
classes.
+ stc_using(value);
+ stc_using(data);
+ stc_using(pset);
+ stc_using(delegatee);
+
+ torus_image();
+ torus_image(I& ima);
+
+ const pset& impl_points() const;
+ point relocate(const point& p) const;
+
+ bool impl_owns_(const point& p) const;
+
+ rvalue impl_read(const point& p) const;
+ lvalue impl_read_write(const point& p);
+ void impl_write(const point& p, const value& v);
+
+ delegatee& impl_image();
+ const delegatee& impl_image() const;
+
+ }; // end of torus_image<I>
+
+
+
+ template <typename I, typename D>
+ bool prepare(torus_image<I>& target, with_t, const D& dat);
+
+ template <typename I>
+ bool init_(Image<I>* this_,
+ const torus_image<I>& data);
+
+ template <typename Ps, typename I>
+ bool init_(torus_pset<Ps>* this_,
+ const torus_image<I>& data);
+
+
+
+ template <typename I>
+ torus_image<const I> torus(const Image<I>& ima);
+
+ template <typename I>
+ torus_image<I> torus(Mutable_Image<I>& ima);
+
+ template <typename I>
+ inplace_< torus_image<I> > torus(inplace_<I> ima);
+
+
+
+# ifndef OLN_INCLUDE_ONLY
+
+ template <typename I>
+ torus_image<I>::torus_image()
+ {
+ }
+
+ template <typename I>
+ torus_image<I>::torus_image(I& ima)
+ {
+ precondition(exact(ima).has_data());
+ this->data_ = new data(ima, pset(ima.points()));
+ }
+
+ template <typename I>
+ const typename torus_image<I>::pset&
+ torus_image<I>::impl_points() const
+ {
+ assert(this->has_data());
+ return this->data_->second;
+ }
+
+ template <typename I>
+ typename torus_image<I>::point
+ torus_image<I>::relocate(const typename torus_image<I>::point& p)
const
+ {
+ assert(this->has_data());
+ return this->data_->second.relocate(p);
+ }
+
+ template <typename I>
+ bool
+ torus_image<I>::impl_owns_(const typename torus_image<I>::point& p)
const
+ {
+ return this->image().owns_(this->relocate(p));
+ }
+
+ template <typename I>
+ typename torus_image<I>::rvalue
+ torus_image<I>::impl_read(const typename torus_image<I>::point& p)
const
+ {
+ assert(this->has_data());
+ assert(this->image().has_data());
+ return this->image()(this->relocate(p));
+ }
+
+ template <typename I>
+ typename torus_image<I>::lvalue
+ torus_image<I>::impl_read_write(const typename torus_image<I>::point&
p)
+ {
+ assert(this->image().has_data());
+ return this->image()(this->relocate(p));
+ }
+
+ template <typename I>
+ void
+ torus_image<I>::impl_write(const typename torus_image<I>::point& p,
+ const typename torus_image<I>::value& v)
+ {
+ assert(this->image().has_data());
+ this->image().write_(this->relocate(p), v);
+ }
+
+ template <typename I>
+ typename torus_image<I>::delegatee&
+ torus_image<I>::impl_image()
+ {
+ assert(this->has_data());
+ return this->data_->first;
+ }
+
+ template <typename I>
+ const typename torus_image<I>::delegatee&
+ torus_image<I>::impl_image() const
+ {
+ assert(this->has_data());
+ return this->data_->first;
+ }
+
+
+ template <typename I>
+ torus_image<const I> torus(const Image<I>& ima)
+ {
+ torus_image<const I> tmp(exact(ima));
+ return tmp;
+ }
+
+ template <typename I>
+ torus_image<I> torus(Mutable_Image<I>& ima)
+ {
+ torus_image<I> tmp(exact(ima));
+ return tmp;
+ }
+
+ template <typename I>
+ inplace_< torus_image<I> > torus(inplace_<I> ima)
+ {
+ torus_image<I> tmp_ = torus(ima.unwrap());
+ inplace_< torus_image<I> > tmp(tmp_);
+ return tmp;
+ }
+
+
+ template <typename I, typename D>
+ bool prepare(torus_image<I>& target, with_t, const D& dat)
+ {
+ precondition(not target.has_data());
+
+ target.data__() = new typename torus_image<I>::data;
+ bool ima_ok = prepare(target.data__()->first, with, dat);
+ bool pset_ok = init(target.data__()->second, with, dat);
+ postcondition(ima_ok);
+ postcondition(pset_ok);
+ return ima_ok and pset_ok;
+ }
+
+ template <typename I>
+ bool init_(Image<I>* this_,
+ const torus_image<I>& data)
+ {
+ exact(*this_) = data.image();
+ return true;
+ }
+
+ template <typename Ps, typename I>
+ bool init_(torus_pset<Ps>* this_,
+ const torus_image<I>& data)
+ {
+ exact(*this_) = data.points();
+ return true;
+ }
+
+# endif // ! OLN_INCLUDE_ONLY
+
+} // end of namespace oln
+
+
+#endif // ! OLN_CORE_GEN_TORUS_IMAGE_HH
Index: oln/core/internal/op_image_through_fv2v.hh
--- oln/core/internal/op_image_through_fv2v.hh (revision 0)
+++ oln/core/internal/op_image_through_fv2v.hh (revision 0)
@@ -0,0 +1,193 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef OLN_CORE_INTERNAL_OP_IMAGE_THROUGH_FV2V_HH
+# define OLN_CORE_INTERNAL_OP_IMAGE_THROUGH_FV2V_HH
+
+# include <oln/core/internal/image_base.hh>
+# include <oln/core/concept/function.hh>
+# include <oln/core/gen/op.hh>
+
+
+namespace oln
+{
+
+
+# define current \
+ special_op_< stc::is<Image>, I, through, stc::is<Function_v2v>, F
>
+
+
+ // Fwd decl.
+ namespace internal { template <typename I, typename F> class current; }
+
+
+ // Super type.
+ template <typename I, typename F>
+ struct super_trait_< internal::current >
+ {
+ typedef internal::value_morpher_< op_<I, through, F> > ret;
+ };
+
+
+# define super \
+ super_trait_< internal::current >::ret
+
+
+ // Virtual types.
+ template <typename I, typename F>
+ struct vtypes< internal::current >
+ {
+ typedef I delegatee;
+ typedef internal::pair<I,F> data;
+
+ typedef oln_result(F) rvalue;
+ typedef mlc_basic(rvalue) value;
+
+ typedef typename mlc::if_< mlc::and_list_< mlc_is_not_const(I),
+ stc_is_found_type(I, lvalue),
+ mlc_is_reference(oln_result(F)),
+ mlc_is_not_const(oln_result(F)) >,
+ stc_find_type(I, lvalue),
+ stc::not_delegated >::ret lvalue;
+
+ typedef op_<oln_plain(I), through, F> plain;
+ typedef op_<pl::rec<I>, through, F> skeleton;
+ };
+
+
+ namespace internal
+ {
+
+ /// Implementation class for the result of "Function_v2v F << Image
I".
+
+ template <typename I, typename F>
+ class current : public super
+ {
+ typedef op_<I, through, F> Exact;
+ public:
+
+ stc_using(delegatee);
+ stc_using(data);
+
+ stc_using(psite);
+ stc_using(value);
+ stc_using(rvalue);
+ typedef stc_find_type(Exact, lvalue) lvalue; // FIXME: macro; propagate in similar
classes.
+
+ delegatee& impl_image();
+ const delegatee& impl_image() const;
+
+ rvalue impl_read(const psite& p) const;
+ lvalue impl_read_write(const psite& p);
+ void impl_write(const psite& p, const value& v);
+
+ const F& fun() const;
+
+ protected:
+ special_op_();
+ special_op_(I& ima, F& f);
+ };
+
+
+# ifndef OLN_INCLUDE_ONLY
+
+ template <typename I, typename F>
+ current::special_op_()
+ {
+ }
+
+ template <typename I, typename F>
+ current::special_op_(I& ima, F& f)
+ {
+ this->data_ = new data(ima, f);
+ }
+
+ template <typename I, typename F>
+ typename current::delegatee&
+ current::impl_image()
+ {
+ assert(this->has_data());
+ return this->data_->first;
+ }
+
+ template <typename I, typename F>
+ const typename current::delegatee&
+ current::impl_image() const
+ {
+ assert(this->has_data());
+ return this->data_->first;
+ }
+
+ template <typename I, typename F>
+ typename current::rvalue
+ current::impl_read(const typename current::psite& p) const
+ {
+ assert(this->image().has_data());
+ return this->fun()(this->image()(p));
+ }
+
+ template <typename I, typename F>
+ typename current::lvalue
+ current::impl_read_write(const typename current::psite& p)
+ {
+ assert(this->image().has_data());
+ return this->fun()(this->image()(p));
+ }
+
+ template <typename I, typename F>
+ void
+ current::impl_write(const typename current::psite& p,
+ const typename current::value& v)
+ {
+ assert(this->image().has_data());
+ this->image()(p) = v;
+ }
+
+ template <typename I, typename F>
+ const F&
+ current::fun() const
+ {
+ assert(this->has_data());
+ return this->data_->second;
+ }
+
+# endif // ! OLN_INCLUDE_ONLY
+
+ } // end of namespace oln::internal
+
+
+ // FIXME: Add init.
+
+
+# undef super
+# undef current
+
+
+} // end of namespace oln
+
+
+#endif // ! OLN_CORE_INTERNAL_OP_IMAGE_THROUGH_FV2V_HH
Index: oln/core/internal/dpoint_base.hh
--- oln/core/internal/dpoint_base.hh (revision 935)
+++ oln/core/internal/dpoint_base.hh (working copy)
@@ -66,6 +66,8 @@
namespace internal
{
+ // FIXME: Factor code for classes defined over vectors (dpoint_base_ and
point_base_).
+
template <typename Exact>
class dpoint_base_ : public Dpoint<Exact>
{
@@ -88,14 +90,15 @@
bool impl_op_less_(const Exact& rhs) const;
Exact& impl_op_plus_equal_(const Exact& rhs);
-
Exact& impl_op_minus_equal_(const Exact& rhs);
+ Exact& impl_op_mod_equal_(const Exact& rhs);
Exact impl_op_unary_minus_() const;
typedef xtd::vec<n, coord> vec_t;
const vec_t& vec() const;
vec_t& vec();
+ void set_all(const coord& c);
protected:
dpoint_base_();
@@ -138,14 +141,22 @@
Exact& dpoint_base_<Exact>::impl_op_plus_equal_(const Exact& rhs)
{
v_ += rhs.v_;
- return *exact(this);
+ return exact(*this);
}
template <typename Exact>
Exact& dpoint_base_<Exact>::impl_op_minus_equal_(const Exact& rhs)
{
v_ -= rhs.v_;
- return *exact(this);
+ return exact(*this);
+ }
+
+ template <typename Exact>
+ Exact& dpoint_base_<Exact>::impl_op_mod_equal_(const Exact& rhs)
+ {
+ for (unsigned i = 0; i < n; ++i)
+ v_[i] %= rhs.v_[i];
+ return exact(*this);
}
template <typename Exact>
@@ -171,6 +182,13 @@
}
template <typename Exact>
+ void
+ dpoint_base_<Exact>::set_all(const typename
dpoint_base_<Exact>::coord& c)
+ {
+ v_.set_all(c);
+ }
+
+ template <typename Exact>
dpoint_base_<Exact>::dpoint_base_()
{
}
@@ -183,7 +201,7 @@
point_base_<Exact>::impl_op_plus_equal_(const typename
point_base_<Exact>::dpoint& rhs)
{
this->v_ += rhs.vec();
- return *exact(this);
+ return exact(*this);
}
template <typename Exact>
@@ -191,7 +209,7 @@
point_base_<Exact>::impl_op_minus_equal_(const typename
point_base_<Exact>::dpoint& rhs)
{
this->v_ -= rhs.vec();
- return *exact(this);
+ return exact(*this);
}
template <typename Exact>
Index: oln/core/internal/box.hh
--- oln/core/internal/box.hh (revision 935)
+++ oln/core/internal/box.hh (working copy)
@@ -154,7 +154,8 @@
public:
stc_using(point);
- box_fwd_piter_(const Point_Set<B>& b);
+ template <typename Ps>
+ box_fwd_piter_(const Point_Set<Ps>& ps);
void impl_start();
void impl_next();
@@ -180,7 +181,8 @@
public:
stc_using(point);
- box_bkd_piter_(const Point_Set<B>& b);
+ template <typename Ps>
+ box_bkd_piter_(const Point_Set<Ps>& ps);
void impl_start();
void impl_next();
@@ -300,8 +302,9 @@
// -------------------- box_fwd_piter_<B>
template <typename B>
- box_fwd_piter_<B>::box_fwd_piter_(const Point_Set<B>& b)
- : b_(exact(b))
+ template <typename Ps>
+ box_fwd_piter_<B>::box_fwd_piter_(const Point_Set<Ps>& ps)
+ : b_(ps.bbox())
{
nop_ = b_.pmax();
++nop_[0];
@@ -364,8 +367,9 @@
// -------------------- box_bkd_piter_<P>
template <typename B>
- box_bkd_piter_<B>::box_bkd_piter_(const Point_Set<B>& b)
- : b_(exact(b))
+ template <typename Ps>
+ box_bkd_piter_<B>::box_bkd_piter_(const Point_Set<Ps>& ps)
+ : b_(ps.bbox())
{
nop_ = b_.pmin();
--nop_[0];
Index: oln/core/internal/image_ops.hh
--- oln/core/internal/image_ops.hh (revision 935)
+++ oln/core/internal/image_ops.hh (working copy)
@@ -33,6 +33,7 @@
# include <oln/core/internal/op_image_such_as_fp2b.hh>
# include <oln/core/internal/op_fp2v_over_pset.hh>
# include <oln/core/internal/op_fv2v_applied_on_image.hh>
+# include <oln/core/internal/op_image_through_fv2v.hh>
# include <oln/core/gen/literal.hh>
@@ -65,6 +66,12 @@
oln_decl_op_applied_on(Function_v2v, Image);
+ // Image >> Function_v2v ( f(ima), i.e., for all p, ( f(ima) )(p) = f(
ima(p) ) )
+
+ oln_decl_op_through(Image, Function_v2v);
+ oln_decl_inplace_image_op(through, >>, Function_v2v);
+
+
// Specialization "f : P -> V over Point_Set".
@@ -187,6 +194,31 @@
}
+ // Specialization
+
+ template <typename I, typename W, typename V>
+ inplace_< op_<const I, through, const fun_v2v_<W (*)(V)> > >
+ operator >> (const Image<I>& ima, W (*f)(V))
+ {
+ op_<const I, through, const fun_v2v_<W (*)(V)> > tmp(f, exact(ima));
+ return tmp;
+ }
+
+ template <typename I, typename W, typename V>
+ op_<I, through, const fun_v2v_<W (*)(V)> >
+ operator >> (Mutable_Image<I>& ima, W (*f)(V))
+ {
+ op_<I, through, const fun_v2v_<W (*)(V)> > tmp(exact(ima), f);
+ return tmp;
+ }
+
+ template <typename W, typename V, typename I>
+ inplace_< op_<I, through, const fun_v2v_<W (*)(V)> > >
+ operator >> (inplace_<I> ima, W (*f)(V))
+ {
+ return (ima.unwrap() >> f).inplace();
+ }
+
} // end of namespace oln
Index: oln/core/internal/pset_adaptor.hh
--- oln/core/internal/pset_adaptor.hh (revision 935)
+++ oln/core/internal/pset_adaptor.hh (working copy)
@@ -81,6 +81,8 @@
bool impl_has(const point& p) const;
const box& impl_bbox() const;
+ const adapted& adapted_() const { return this->ps_; }
+
protected:
adapted ps_;
pset_adaptor_();
Index: oln/morpho/elementary_erosion.hh
--- oln/morpho/elementary_erosion.hh (revision 935)
+++ oln/morpho/elementary_erosion.hh (working copy)
@@ -106,6 +106,24 @@
// }
// delete[] jump;
// return output;
+
+// std::cout << "fast" << std::endl;
+
+// typedef oln_value(I) T;
+// border::fill(input, oln_max(T));
+// accumulator::min_<T> min;
+
+// oln_plain(I) output;
+// prepare(output, with, input);
+// oln_fast_piter(I) p(input), out(output);
+// oln_fast_niter(I) n(p, input);
+// for_all(p)
+// {
+// for_all(n)
+// min.take(*n);
+// *out = min.value();
+// }
+// return output;
// }
Index: oln/level/local.hh
Index: oln/level/apply_local.hh