https://svn.lrde.epita.fr/svn/oln/trunk/olena
Index: ChangeLog
from Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
Add the image type ''function: p -> v over a point set''.
* oln/core/gen/image_pset_piter.hh: Remove; obsolete.
* oln/core/internal/image_base.hh: Move end of file to...
* oln/core/internal/image_ops.hh: ...this new file.
(operator/): New.
* oln/core/internal/op_fp2v_over_pset.hh: New.
* oln/core/gen/op.hh (oln_decl_op_over, over): New.
* oln/core/gen/single_value_image.hh,
* oln/core/internal/op_image_plus_nbh.hh: Cosmetic changes.
* oln/core/internal/f_pset_to_plain_image.hh
(pset_to_plain_image__): Fix version op_<S, such_as, F_p2b>.
gen/op.hh | 2
gen/single_value_image.hh | 4 -
internal/f_pset_to_plain_image.hh | 7 -
internal/image_base.hh | 76 -------------------
internal/image_ops.hh | 129 ++++++++++++++++++++++++++++++++
internal/op_fp2v_over_pset.hh | 151 ++++++++++++++++++++++++++++++++++++++
internal/op_image_plus_nbh.hh | 8 +-
7 files changed, 293 insertions(+), 84 deletions(-)
Index: oln/core/gen/op.hh
--- oln/core/gen/op.hh (revision 922)
+++ oln/core/gen/op.hh (working copy)
@@ -77,6 +77,7 @@
# define oln_decl_op_plus(Lconcept, Rconcept) oln_decl_op_( plus,
Lconcept, +, Rconcept)
# define oln_decl_op_such_as(Lconcept, Rconcept) oln_decl_op_( such_as,
Lconcept, |, Rconcept)
# 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)
// ...
@@ -91,6 +92,7 @@
struct plus;
struct such_as;
struct restricted_to;
+ struct over;
/// \}
Index: oln/core/gen/single_value_image.hh
--- oln/core/gen/single_value_image.hh (revision 922)
+++ oln/core/gen/single_value_image.hh (working copy)
@@ -45,11 +45,11 @@
template <typename Ps, typename T>
struct vtypes< single_value_image<Ps, T> >
{
- typedef typename Ps::point point;
+ typedef oln_point(Ps) point;
typedef point psite;
typedef Ps pset;
- typedef typename point::coord coord;
+ typedef oln_coord(point) coord;
typedef T value;
typedef const T& rvalue;
Index: oln/core/internal/image_ops.hh
--- oln/core/internal/image_ops.hh (revision 0)
+++ oln/core/internal/image_ops.hh (revision 0)
@@ -0,0 +1,129 @@
+// 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_IMAGE_OPS_HH
+# define OLN_CORE_INTERNAL_IMAGE_OPS_HH
+
+# include <oln/core/internal/f_ch_value.hh>
+# include <oln/core/internal/op_image_restricted_to_pset.hh>
+# include <oln/core/internal/op_image_such_as_fp2b.hh>
+# include <oln/core/internal/op_fp2v_over_pset.hh>
+
+
+
+namespace oln
+{
+
+ // Image | Point_Set ( ima restricted_to pset )
+
+ oln_decl_op_restricted_to(Image, Point_Set);
+
+
+
+ // Image | Function_p2b ( ima such_as "f : p -> b"
+ // is ima restricted_to (ima.points such_as f) )
+ oln_decl_op_such_as(Image, Function_p2b);
+
+
+
+ // Function_p2v / Point_Set ( ima defined by: "f : p -> v" over pset )
+
+ oln_decl_op_over(Function_p2v, Point_Set);
+
+
+
+
+ // Specialization "f : P -> V over Point_Set".
+
+ template <typename V, typename P, typename S>
+ op_<const fun_p2v_<V (*)(P)>, over, const S>
+ operator / (V (*f)(P), const Point_Set<S>& pts)
+ {
+ typedef oln_strip_(P) P_;
+ mlc::assert_< mlc_is_a(P_, Point) >::check(); // FIXME: Add err msg.
+ mlc::assert_equal_< P_, oln_point(S) >::check();
+ op_<const fun_p2v_<V (*)(P)>, over, const S> tmp(f, exact(pts));
+ return tmp;
+ }
+
+
+
+ // Specialization "Image such_as f : P -> B".
+
+ template <typename I, typename B, typename P>
+ op_<const I, such_as, const fun_p2b_<B (*)(P)> >
+ operator | (const Image<I>& ima, B (*f)(P))
+ {
+ typedef oln_strip_(P) P_;
+ mlc::assert_< mlc_is_a(P_, Point) >::check(); // FIXME: Add err msg.
+ mlc::assert_equal_< P_, oln_point(I) >::check();
+ op_<const I, such_as, const fun_p2b_<B (*)(P)> > tmp(exact(ima), f);
+ return tmp;
+ }
+
+ template <typename I, typename B, typename P>
+ op_<I, such_as, const fun_p2b_<B (*)(P)> >
+ operator | (Image<I>& ima, B (*f)(P))
+ {
+ typedef oln_strip_(P) P_;
+ mlc::assert_< mlc_is_a(P_, Point) >::check(); // FIXME: Add err msg.
+ mlc::assert_equal_< P_, oln_point(I) >::check();
+ op_<I, such_as, const fun_p2b_<B (*)(P)> > tmp(exact(ima), f);
+ return tmp;
+ }
+
+
+ // Specialization "Image such_as ima : P -> B".
+
+ template <typename I, typename J>
+ op_<const I, such_as, const fun_p2b_< Binary_Image<J> > >
+ operator | (const Image<I>& ima, const Binary_Image<J>& f_ima_b)
+ {
+ precondition(f_ima_b.points() >= ima.points());
+ mlc::assert_equal_< oln_point(I), oln_point(J) >::check();
+ op_<const I, such_as, const fun_p2b_< Binary_Image<J> > >
tmp(exact(ima), f_ima_b);
+ return tmp;
+ }
+
+ template <typename I, typename J>
+ op_<I, such_as, const fun_p2b_< Binary_Image<J> > >
+ operator | (Image<I>& ima, const Binary_Image<J>& f_ima_b)
+ {
+ precondition(f_ima_b.points() >= ima.points());
+ mlc::assert_equal_< oln_point(I), oln_point(J) >::check();
+ op_<I, such_as, const fun_p2b_< Binary_Image<J> > > tmp(exact(ima),
f_ima_b);
+ return tmp;
+ }
+
+
+ // FIXME: What about Mutable_Image so that "ima | something" can be
left-value?
+
+
+} // end of namespace oln
+
+
+#endif // ! OLN_CORE_INTERNAL_IMAGE_OPS_HH
Index: oln/core/internal/image_base.hh
--- oln/core/internal/image_base.hh (revision 922)
+++ oln/core/internal/image_base.hh (working copy)
@@ -473,80 +473,8 @@
-
-/// \{
-/// FIXME: Bad!
-
-# include <oln/core/internal/f_ch_value.hh>
-# include <oln/core/internal/op_image_restricted_to_pset.hh>
-# include <oln/core/internal/op_image_such_as_fp2b.hh>
-
-namespace oln
-{
- // Image | Point_Set ( ima restricted_to pset )
-
- oln_decl_op_restricted_to(Image, Point_Set);
-
-
- // Image | Function_p2b ( ima such_as "f : p -> b"
- // is ima restricted_to (ima.points such_as f) )
- oln_decl_op_such_as(Image, Function_p2b);
-
-
- // Specialization "Image such_as f : P -> B".
-
- template <typename I, typename B, typename P>
- op_<const I, such_as, const fun_p2b_<B (*)(P)> >
- operator | (const Image<I>& ima, B (*f)(P))
- {
- typedef oln_strip_(P) P_;
- mlc::assert_< mlc_is_a(P_, Point) >::check(); // FIXME: Add err msg.
- mlc::assert_equal_< P_, oln_point(I) >::check();
- op_<const I, such_as, const fun_p2b_<B (*)(P)> > tmp(exact(ima), f);
- return tmp;
- }
-
- template <typename I, typename B, typename P>
- op_<I, such_as, const fun_p2b_<B (*)(P)> >
- operator | (Image<I>& ima, B (*f)(P))
- {
- typedef oln_strip_(P) P_;
- mlc::assert_< mlc_is_a(P_, Point) >::check(); // FIXME: Add err msg.
- mlc::assert_equal_< P_, oln_point(I) >::check();
- op_<I, such_as, const fun_p2b_<B (*)(P)> > tmp(exact(ima), f);
- return tmp;
- }
-
-
- // Specialization "Image such_as ima : P -> B".
-
- template <typename I, typename J>
- op_<const I, such_as, const fun_p2b_< Binary_Image<J> > >
- operator | (const Image<I>& ima, const Binary_Image<J>& f_ima_b)
- {
- precondition(f_ima_b.points() >= ima.points());
- mlc::assert_equal_< oln_point(I), oln_point(J) >::check();
- op_<const I, such_as, const fun_p2b_< Binary_Image<J> > >
tmp(exact(ima), f_ima_b);
- return tmp;
- }
-
- template <typename I, typename J>
- op_<I, such_as, const fun_p2b_< Binary_Image<J> > >
- operator | (Image<I>& ima, const Binary_Image<J>& f_ima_b)
- {
- precondition(f_ima_b.points() >= ima.points());
- mlc::assert_equal_< oln_point(I), oln_point(J) >::check();
- op_<I, such_as, const fun_p2b_< Binary_Image<J> > > tmp(exact(ima),
f_ima_b);
- return tmp;
- }
-
-
- // FIXME: What about Mutable_Image so that "ima | something" can be
left-value?
-
-
-} // end of namespace oln
-
-/// \}
+// FIXME: Bad!
+# include <oln/core/internal/image_ops.hh>
Index: oln/core/internal/op_fp2v_over_pset.hh
--- oln/core/internal/op_fp2v_over_pset.hh (revision 0)
+++ oln/core/internal/op_fp2v_over_pset.hh (revision 0)
@@ -0,0 +1,151 @@
+// 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_FP2V_OVER_PSET
+# define OLN_CORE_INTERNAL_OP_FP2V_OVER_PSET
+
+# include <oln/core/concept/point_set.hh>
+# include <oln/core/concept/function.hh>
+# include <oln/core/internal/image_base.hh>
+# include <oln/core/internal/f_pset_to_plain_image.hh>
+# include <oln/core/gen/op.hh>
+
+
+namespace oln
+{
+
+# define current \
+ special_op_< stc::is<Function_p2v>, F, over, stc::is<Point_Set>, S
>
+
+
+ // Super type.
+ template <typename F, typename S>
+ struct super_trait_< internal::current >
+ {
+ typedef internal::primitive_image_< op_<F, over, S> > ret;
+ };
+
+
+ /// Virtual types.
+ template <typename F, typename S>
+ struct vtypes< internal::current >
+ {
+ typedef op_<F, over, S> Exact;
+
+ typedef oln_point(S) point;
+ typedef point psite;
+ typedef S pset;
+
+ typedef oln_coord(point) coord;
+
+ typedef oln_result(F) value; // FIXME: Unconst, unref!
+ typedef oln_result(F) rvalue;
+
+ typedef internal::pair<F, S> data;
+
+ typedef oln_f_pset_to_plain_image(S, value) plain;
+ typedef void skeleton; // FIXME: check that this type is never accessed?
+ };
+
+
+ namespace internal
+ {
+
+ /// Implementation class for the result of "Function_p2v F / Point_Set S".
+
+ template <typename F, typename S>
+ class current : public internal::primitive_image_< op_<F, over, S> >
+ {
+ typedef internal::primitive_image_< op_<F, over, S> > super;
+ public:
+ stc_using(data);
+ stc_using(point);
+ stc_using(rvalue);
+
+ bool impl_owns_(const point& p) const;
+ rvalue impl_read(const point& p) const;
+ const S& impl_points() const;
+
+ protected:
+ special_op_();
+ special_op_(F& fun, S& pts);
+ };
+
+ } // end of namespace oln::internal
+
+
+
+# ifndef OLN_INCLUDE_ONLY
+
+ namespace internal
+ {
+
+ template <typename F, typename S>
+ current::special_op_()
+ {
+ }
+
+ template <typename F, typename S>
+ current::special_op_(F& fun, S& pts)
+ {
+ this->data_ = new data(fun, pts);
+ }
+
+ template <typename F, typename S>
+ bool
+ current::impl_owns_(const typename current::point& p) const
+ {
+ assert(this->has_data());
+ return this->data_->second.has(p);
+ }
+
+ template <typename F, typename S>
+ typename current::rvalue
+ current::impl_read(const typename current::point& p) const
+ {
+ assert(this->has_data());
+ return this->data_->first(p);
+ }
+
+ template <typename F, typename S>
+ const S&
+ current::impl_points() const
+ {
+ assert(this->has_data());
+ return this->data_->second;
+ }
+
+ } // end of namespace oln::internal
+
+# endif // ! OLN_INCLUDE_ONLY
+
+# undef current
+
+} // end of namespace oln
+
+
+#endif // ! OLN_CORE_INTERNAL_OP_FP2V_OVER_PSET_HH
Index: oln/core/internal/f_pset_to_plain_image.hh
--- oln/core/internal/f_pset_to_plain_image.hh (revision 922)
+++ oln/core/internal/f_pset_to_plain_image.hh (working copy)
@@ -101,12 +101,11 @@
typedef oln_f_grid_to_plain_image(oln_grid(P), T) ret;
};
- template <typename S, typename F, typename T>
- struct pset_to_plain_image__< op_<S, such_as, F>, T >
+ template <typename S, typename F_p2b, typename T>
+ struct pset_to_plain_image__< op_<S, such_as, F_p2b>, T >
{
- typedef op_<S, such_as, F> Ps;
typedef typename f_pset_to_plain_image_<S, T>::ret I;
- typedef op_<I, restricted_to, Ps> ret;
+ typedef op_<I, such_as, F_p2b> ret;
};
/// \}
Index: oln/core/internal/op_image_plus_nbh.hh
--- oln/core/internal/op_image_plus_nbh.hh (revision 922)
+++ oln/core/internal/op_image_plus_nbh.hh (working copy)
@@ -45,12 +45,12 @@
oln_decl_instant_value(nbh);
- /// Fwd decls.
+ // Fwd decls.
template <typename Exact> struct Image;
template <typename Exact> struct Neighborhood;
- /// Super type.
+ // Super type.
template <typename I, typename N>
struct super_trait_< internal::current >
{
@@ -58,7 +58,7 @@
};
- /// Virtual types.
+ // Virtual types.
template <typename I, typename N>
struct vtypes< internal::current >
{
@@ -224,7 +224,7 @@
return ima_ok and nbh_ok;
}
-# endif // OLN_INCLUDE_ONLY
+# endif // ! OLN_INCLUDE_ONLY
# undef current