https://svn.lrde.epita.fr/svn/oln/trunk/olena
Index: ChangeLog
from Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
Update windows and neighborhoods + remove obsolete files.
* oln/core/abstract/window.hh: Rename as...
* oln/core/concept/window.hh: ...this and update.
* oln/core/abstract/neighborhood.hh: Rename as...
* oln/core/concept/neighborhood.hh: ...this and update.
* oln/core/gen/fwd_qiter_win.hh: Rename as...
* oln/core/gen/dpoints_piter.hh: ...this and update.
* oln/core/internal/dpoints_impl.hh: New.
* oln/core/2d/neighb2d.hh: Update.
* oln/core/internal/image_base.hh (plain_primitive_image_): New.
* oln/core/2d/image2d.hh (image2d): Inherit from plain_primitive_image_.
* oln/core/2d/window2d.hh: Update
(mk_square): New.
* oln/core/gen/neighb.hh: Update.
* oln/core/internal/image_selectors.hh: Fix.
* oln/core/internal/dpoint_base.hh (include): Fix.
* oln/core/type.hh,
* oln/core/typedefs.hh,
* oln/core/macros.hh,
* oln/core/neighborhood_entry.hh,
* oln/core/gen/bkd_qiter_win.hh,
* oln/core/gen/grid.hh,
* oln/core/gen/topo_add_isubset.hh,
* oln/core/gen/topo_bbox.hh,
* oln/core/gen/fwd_niter_neighb.hh,
* oln/core/gen/topo_lbbox.hh,
* oln/core/gen/bkd_niter_neighb.hh,
* oln/core/gen/topo_add_nbh.hh,
* oln/core/internal/topology_morpher.hh: Remove.
2d/image2d.hh | 7 -
2d/neighb2d.hh | 42 +++---
2d/window2d.hh | 47 +++++++
concept/neighborhood.hh | 66 ++--------
concept/window.hh | 71 ++---------
gen/dpoints_piter.hh | 267 +++++++++++++++++++++++++++++---------------
gen/neighb.hh | 106 ++++-------------
gen/window.hh | 117 ++++++-------------
internal/dpoint_base.hh | 1
internal/dpoints_impl.hh | 125 ++++++++------------
internal/image_base.hh | 47 ++++++-
internal/image_selectors.hh | 2
12 files changed, 431 insertions(+), 467 deletions(-)
Index: oln/core/concept/window.hh
--- oln/core/concept/window.hh (revision 854)
+++ oln/core/concept/window.hh (working copy)
@@ -1,4 +1,4 @@
-// Copyright (C) 2006 EPITA Research and Development Laboratory
+// Copyright (C) 2006, 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
@@ -25,84 +25,39 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef OLN_CORE_ABSTRACT_WINDOW_HH
-# define OLN_CORE_ABSTRACT_WINDOW_HH
+#ifndef OLN_CORE_CONCEPT_WINDOW_HH
+# define OLN_CORE_CONCEPT_WINDOW_HH
-# include <oln/core/typedefs.hh>
+# include <oln/core/equipment.hh>
namespace oln
{
- namespace abstract { template <typename E> class window; }
+ /// Concept-class "Window".
-
- template <typename E>
- struct set_super_type< abstract::window<E> >
- {
- typedef mlc::none ret;
- };
-
-
- namespace abstract
- {
-
-
- /// Abstract window class.
- template <typename E>
- class window : public virtual stc::any__simple<E>,
- public virtual oln::type
- {
- public:
-
- bool is_valid() const;
-
- struct decl
+ template <typename Exact>
+ struct Window : public Any<Exact>
{
- oln_virtual_typedef(grid);
-
- decl();
- };
+ stc_typename(grid);
protected:
+ Window();
- window();
- ~window();
-
- }; // end of class oln::abstract::window<E>
+ }; // end of oln::Window<Exact>
# ifndef OLN_INCLUDE_ONLY
- template <typename E>
- bool window<E>::is_valid() const
- {
- return this->exact().impl_is_valid();
- }
-
- template <typename E>
- window<E>::window()
- {
- }
-
- template <typename E>
- window<E>::~window()
- {
- decl();
- }
-
- template <typename E>
- window<E>::decl::decl()
+ template <typename Exact>
+ Window<Exact>::Window()
{
}
# endif
-
- } // end of namespace oln::abstract
-
} // end of namespace oln
-#endif // ! OLN_CORE_ABSTRACT_WINDOW_HH
+#endif // ! OLN_CORE_CONCEPT_WINDOW_HH
Index: oln/core/concept/neighborhood.hh
--- oln/core/concept/neighborhood.hh (revision 854)
+++ oln/core/concept/neighborhood.hh (working copy)
@@ -1,4 +1,4 @@
-// Copyright (C) 2006 EPITA Research and Development Laboratory
+// Copyright (C) 2006, 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
@@ -25,79 +25,39 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef OLN_CORE_ABSTRACT_NEIGHBORHOOD_HH
-# define OLN_CORE_ABSTRACT_NEIGHBORHOOD_HH
+#ifndef OLN_CORE_CONCEPT_NEIGHBORHOOD_HH
+# define OLN_CORE_CONCEPT_NEIGHBORHOOD_HH
-# include <oln/core/typedefs.hh>
+# include <oln/core/equipment.hh>
namespace oln
{
- namespace abstract
- {
-
-
- /// Abstract neighborhood class.
- template <typename E>
- class neighborhood : public virtual stc::any__simple<E>,
- public virtual oln::type
- {
- public:
-
- bool is_valid() const;
+ /// Concept-class "Neighborhood".
- struct decl
+ template <typename Exact>
+ struct Neighborhood : public Any<Exact>
{
- oln_virtual_typedef(grid);
-
- decl();
- };
+ stc_typename(grid);
protected:
+ Neighborhood();
- neighborhood();
- ~neighborhood();
-
- }; // end of class oln::abstract::neighborhood<E>
+ }; // end of oln::Neighborhood<Exact>
# ifndef OLN_INCLUDE_ONLY
- template <typename E>
- bool neighborhood<E>::is_valid() const
- {
- return this->exact().impl_is_valid();
- }
-
- template <typename E>
- neighborhood<E>::neighborhood()
- {
- }
-
- template <typename E>
- neighborhood<E>::~neighborhood()
- {
- decl();
- }
-
- template <typename E>
- neighborhood<E>::decl::decl()
+ template <typename Exact>
+ Neighborhood<Exact>::Neighborhood()
{
}
# endif
-
- } // end of namespace oln::abstract
-
} // end of namespace oln
-
-// # include <oln/core/abstract/neighborhood_hierarchies.hh>
-
-
-
-#endif // ! OLN_CORE_ABSTRACT_NEIGHBORHOOD_HH
+#endif // ! OLN_CORE_CONCEPT_NEIGHBORHOOD_HH
Index: oln/core/2d/neighb2d.hh
--- oln/core/2d/neighb2d.hh (revision 854)
+++ oln/core/2d/neighb2d.hh (working copy)
@@ -1,4 +1,4 @@
-// Copyright (C) 2001, 2002, 2003, 2004, 2006 EPITA Research and
+// Copyright (C) 2001, 2002, 2003, 2004, 2006, 2007 EPITA Research and
// Development Laboratory
//
// This file is part of the Olena Library. This library is free
@@ -52,38 +52,38 @@
neighb2d mk_c4()
{
- neighb2d the_;
- the_
- .add(dpoint2d(0, 1))
- .add(dpoint2d(1, 0));
- return the_;
+ neighb2d tmp;
+ tmp
+ .take(dpoint2d(0, 1))
+ .take(dpoint2d(1, 0));
+ return tmp;
}
neighb2d mk_c8()
{
- neighb2d the_;
- the_
- .add(dpoint2d(0, 1))
- .add(dpoint2d(1,-1))
- .add(dpoint2d(1, 0))
- .add(dpoint2d(1, 1));
- return the_;
+ neighb2d tmp;
+ tmp
+ .take(dpoint2d(0, 1))
+ .take(dpoint2d(1,-1))
+ .take(dpoint2d(1, 0))
+ .take(dpoint2d(1, 1));
+ return tmp;
}
neighb2d mk_c2_row()
{
- neighb2d the_;
- the_
- .add(dpoint2d(0, 1));
- return the_;
+ neighb2d tmp;
+ tmp
+ .take(dpoint2d(0, 1));
+ return tmp;
}
neighb2d mk_c2_col()
{
- neighb2d the_;
- the_
- .add(dpoint2d(1, 0));
- return the_;
+ neighb2d tmp;
+ tmp
+ .take(dpoint2d(1, 0));
+ return tmp;
}
# endif
Index: oln/core/2d/image2d.hh
--- oln/core/2d/image2d.hh (revision 854)
+++ oln/core/2d/image2d.hh (working copy)
@@ -46,7 +46,6 @@
struct vtypes< image2d<T> >
{
typedef point2d point;
- typedef point psite;
typedef int coord;
typedef unsigned index;
@@ -65,17 +64,17 @@
struct super_trait_< image2d<T> >
{
typedef image2d<T> current;
- typedef internal::image_base_<current> ret;
+ typedef internal::plain_primitive_image_<current> ret;
};
/// General 2D image class.
template <typename T>
- class image2d : public internal::image_base_< image2d<T> >
+ class image2d : public internal::plain_primitive_image_< image2d<T> >
{
typedef image2d<T> current;
- typedef internal::image_base_<current> super;
+ typedef internal::plain_primitive_image_<current> super;
public:
stc_using(data);
Index: oln/core/2d/window2d.hh
--- oln/core/2d/window2d.hh (revision 854)
+++ oln/core/2d/window2d.hh (working copy)
@@ -28,10 +28,49 @@
#ifndef OLN_CORE_2D_WINDOW2D_HH
# define OLN_CORE_2D_WINDOW2D_HH
-// Headers required for the complete definition of oln::window2d
-// (i.e., oln::window_<dpoint2d>).
-# include <oln/core/2d/aliases.hh>
-# include <oln/core/2d/dpoint2d.hh>
# include <oln/core/gen/window.hh>
+# include <oln/core/2d/dpoint2d.hh>
+
+
+namespace oln
+{
+
+ typedef window_<dpoint2d> window2d;
+
+
+ window2d mk_square(unsigned odd_len);
+
+
+
+# ifndef OLN_INCLUDE_ONLY
+
+ window2d mk_square(unsigned odd_len)
+ {
+ precondition(odd_len % 2 = 1);
+ window2d tmp;
+ int half_len = odd_len / 2;
+ for (int drow = - half_len; drow <= half_len; ++drow)
+ for (int dcol = - half_len; dcol <= half_len; ++dcol)
+ tmp.take(dpoint2d(drow, dcol));
+ return tmp;
+ }
+
+# endif
+
+
+ extern const window2d win3x3;
+ extern const window2d win5x5;
+
+
+# ifndef OLN_INCLUDE_ONLY
+
+ const window2d win3x3 = mk_square(3);
+ const window2d win5x5 = mk_square(5);
+
+# endif
+
+
+} // end of namespace oln
+
#endif // ! OLN_CORE_2D_WINDOW2D_HH
Index: oln/core/gen/dpoints_piter.hh
--- oln/core/gen/dpoints_piter.hh (revision 854)
+++ oln/core/gen/dpoints_piter.hh (working copy)
@@ -1,4 +1,4 @@
-// Copyright (C) 2006 EPITA Research and Development Laboratory
+// Copyright (C) 2006, 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
@@ -25,154 +25,252 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef OLN_CORE_GEN_FWD_QITER_WIN_HH
-# define OLN_CORE_GEN_FWD_QITER_WIN_HH
+#ifndef OLN_CORE_GEN_DPOINTS_PITER_HH
+# define OLN_CORE_GEN_DPOINTS_PITER_HH
-# include <oln/core/abstract/iterator_on_points.hh>
-# include <oln/core/abstract/window.hh>
-# include <oln/core/gen/window.hh>
+# include <oln/core/concept/iterator_on_points.hh>
+# include <oln/core/concept/window.hh>
+# include <oln/core/concept/neighborhood.hh>
+# include <oln/core/internal/dpoints_impl.hh>
namespace oln
{
- // Forward declaration.
- template <typename point_t> class fwd_qiter_win_;
+ /// Fwd decls.
+ template <typename P> struct dpoints_fwd_piter_;
+ template <typename P> struct dpoints_bkd_piter_;
- // Super type declaration.
- template <typename point_t>
- struct set_super_type< fwd_qiter_win_<point_t> >
+ // Super types.
+ template <typename P>
+ struct super_trait_< dpoints_fwd_piter_<P> >
{
- typedef fwd_qiter_win_<point_t> self_t;
- typedef abstract::iterator_on_points<self_t> ret;
+ typedef dpoints_fwd_piter_<P> current__;
+ typedef Iterator_on_Points<current__> ret;
+ };
+ template <typename P>
+ struct super_trait_< dpoints_bkd_piter_<P> >
+ {
+ typedef dpoints_bkd_piter_<P> current__;
+ typedef Iterator_on_Points<current__> ret;
};
- /// Virtual types associated to oln::fwd_qiter_win_<point_t>.
- template <typename point_t>
- struct vtypes< fwd_qiter_win_<point_t> >
+ /// Virtual types.
+ template <typename P>
+ struct vtypes< dpoints_fwd_piter_<P> >
{
- typedef point_t point_type;
- typedef oln_grid(point_t) grid_type;
+ typedef P point;
+ };
+ template <typename P>
+ struct vtypes< dpoints_bkd_piter_<P> >
+ {
+ typedef P point;
};
- /// Abstract forward point iterator class.
- template <typename point_t>
- class fwd_qiter_win_ : public abstract::iterator_on_points<
fwd_qiter_win_<point_t> >
+ namespace internal
{
- typedef fwd_qiter_win_<point_t> self_t;
- typedef abstract::iterator_on_points<self_t> super_t;
- typedef oln_dpoint(point_t) dpoint_t;
+ /// Class to factor some code.
+
+ template <typename P>
+ class dpoints_piter_impl_ : private mlc::assert_< mlc_is_a(P, Point) >
+ {
+ public:
+
+ void impl_invalidate();
+
+ bool impl_is_valid() const;
+
+ P impl_to_point() const;
+
+ const P* impl_point_adr() const;
+
+ protected:
+
+ const P* p_ref_;
+ const std::vector<typename P::dpoint>* dps_;
+ unsigned n_, i_;
+ P p_;
+
+ // Ctor.
+ template <typename Pl>
+ dpoints_piter_impl_(const Pl& ref,
+ const internal::dpoints_impl_<typename P::dpoint>& data);
+
+ void update_p_();
+ };
+
+ } // end of namespace oln::internal
+
+
+ /// Forward point iterator class on a set of dpoints.
+
+ template <typename P>
+ class dpoints_fwd_piter_ : public Iterator_on_Points< dpoints_fwd_piter_<P>
>,
+ public internal::dpoints_piter_impl_<P>
+ {
public:
- template <typename P, typename W>
- fwd_qiter_win_(const abstract::iterator_on_points<P>& it,
- const abstract::window<W>& win);
-
- template <typename P, typename W>
- fwd_qiter_win_(const abstract::point<P>& p,
- const abstract::window<W>& win);
+ template <typename Pl, typename X>
+ dpoints_fwd_piter_(const Pl& p, const X& win_or_nbh);
void impl_start();
void impl_next();
- void impl_invalidate();
+ }; // end of class oln::dpoints_fwd_piter_<P>
- bool impl_is_valid() const;
- point_t impl_to_point() const;
- const point_t* impl_point_adr() const;
+ /// Backward point iterator class on a set of dpoints.
- protected:
+ template <typename P>
+ class dpoints_bkd_piter_ : public Iterator_on_Points< dpoints_bkd_piter_<P>
>,
+ public internal::dpoints_piter_impl_<P>
+ {
+ public:
+
+ template <typename Pl, typename X>
+ dpoints_bkd_piter_(const Pl& p, const X& win_or_nbh);
- const point_t* p_ref_;
- window_<dpoint_t> win_;
- int i_;
- point_t p_;
+ void impl_start();
+
+ void impl_next();
- }; // end of class oln::fwd_qiter_win_<point_t>
+ }; // end of class oln::dpoints_bkd_piter_<P>
# ifndef OLN_INCLUDE_ONLY
- template <typename point_t>
- template <typename P, typename W>
- fwd_qiter_win_<point_t>::fwd_qiter_win_(const
abstract::iterator_on_points<P>& it,
- const abstract::window<W>& win)
- : p_ref_(it.point_adr()),
- win_(win.exact())
+ namespace internal
{
- precondition(win_.card() > 0);
- this->invalidate();
+
+ template <typename Pl>
+ const Pl* point_adr_(const Point<Pl>& p)
+ {
+ return exact(&p);
}
- template <typename point_t>
- template <typename P, typename W>
- fwd_qiter_win_<point_t>::fwd_qiter_win_(const abstract::point<P>& p,
- const abstract::window<W>& win)
- : p_ref_(&(p.exact())),
- win_(win.exact())
+ template <typename Pl>
+ const typename Pl::point* point_adr_(const Iterator_on_Points<Pl>& p)
{
- precondition(win_.card() > 0);
- this->invalidate();
+ return p.point_adr();
+ }
+
+ template <typename P>
+ template <typename Pl>
+ dpoints_piter_impl_<P>::dpoints_piter_impl_(const Pl& ref,
+ const internal::dpoints_impl_<typename P::dpoint>& data)
+ {
+ p_ref_ = point_adr_(ref);
+ dps_ = &(data.dpoints());
+ n_ = data.size();
+ i_ = n_;
+ postcondition(n_ != 0);
}
- template <typename point_t>
+ template <typename P>
void
- fwd_qiter_win_<point_t>::impl_start()
+ dpoints_piter_impl_<P>::impl_invalidate()
{
- i_ = 0;
- p_ = *p_ref_+ win_.dp(i_);
+ i_ = n_;
+ }
+
+ template <typename P>
+ bool
+ dpoints_piter_impl_<P>::impl_is_valid() const
+ {
+ return i_ != n_;
+ }
+
+ template <typename P>
+ P
+ dpoints_piter_impl_<P>::impl_to_point() const
+ {
+ return p_;
}
- template <typename point_t>
+ template <typename P>
+ const P*
+ dpoints_piter_impl_<P>::impl_point_adr() const
+ {
+ return &p_;
+ }
+
+ template <typename P>
void
- fwd_qiter_win_<point_t>::impl_next()
+ dpoints_piter_impl_<P>::update_p_()
{
- ++i_;
- if (i_ = int(win_.card()))
+ p_ = *p_ref_+ (*dps_)[i_];
+ }
+
+ } // end of namespace oln::internal
+
+
+ // fwd
+
+ template <typename P>
+ template <typename Pl, typename X>
+ dpoints_fwd_piter_<P>::dpoints_fwd_piter_(const Pl& p, const X&
win_or_nbh)
+ :
+ internal::dpoints_piter_impl_<P>(p, exact(win_or_nbh))
{
- this->invalidate();
- return;
}
- p_ = *p_ref_ + win_.dp(i_);
+
+ template <typename P>
+ void
+ dpoints_fwd_piter_<P>::impl_start()
+ {
+ i_ = 0;
+ this->update_p_();
}
- template <typename point_t>
+ template <typename P>
void
- fwd_qiter_win_<point_t>::impl_invalidate()
+ dpoints_fwd_piter_<P>::impl_next()
{
- i_ = -1;
+ if (++i_ = n_)
+ return;
+ this->update_p_();
}
- template <typename point_t>
- bool
- fwd_qiter_win_<point_t>::impl_is_valid() const
+
+ // bkd
+
+ template <typename P>
+ template <typename Pl, typename X>
+ dpoints_bkd_piter_<P>::dpoints_bkd_piter_(const Pl& p, const X&
win_or_nbh)
+ :
+ internal::dpoints_piter_impl_<P>(p, exact(win_or_nbh))
{
- return i_ != -1;
}
- template <typename point_t>
- point_t
- fwd_qiter_win_<point_t>::impl_to_point() const
+ template <typename P>
+ void
+ dpoints_bkd_piter_<P>::impl_start()
{
- return p_;
+ i_ = n_ - 1;
+ this->update_p_();
}
- template <typename point_t>
- const point_t*
- fwd_qiter_win_<point_t>::impl_point_adr() const
+ template <typename P>
+ void
+ dpoints_bkd_piter_<P>::impl_next()
{
- return &p_;
+ if (i_ = 0)
+ {
+ i_ = n_;
+ return;
+ }
+ --i_;
+ this->update_p_();
}
# endif
@@ -180,5 +278,4 @@
} // end of namespace oln
-#endif // ! OLN_CORE_GEN_FWD_QITER_WIN_HH
-
+#endif // ! OLN_CORE_GEN_DPOINTS_PITER_HH
Index: oln/core/gen/neighb.hh
--- oln/core/gen/neighb.hh (revision 854)
+++ oln/core/gen/neighb.hh (working copy)
@@ -1,4 +1,4 @@
-// Copyright (C) 2001, 2003, 2004, 2005, 2006 EPITA Research and
+// Copyright (C) 2001, 2003, 2004, 2005, 2006, 2007 EPITA Research and
// Development Laboratory
//
// This file is part of the Olena Library. This library is free
@@ -29,120 +29,66 @@
#ifndef OLN_CORE_GEN_NEIGHB_HH
# define OLN_CORE_GEN_NEIGHB_HH
-# include <set>
-# include <vector>
-# include <oln/core/neighborhood_entry.hh>
-# include <oln/core/abstract/dpoint.hh>
+# include <oln/core/internal/dpoints_impl.hh>
+# include <oln/core/concept/neighborhood.hh>
namespace oln
{
- // Forward declaration.
- template <typename dpoint> class neighb_;
+ // Fwd decl.
+ template <typename Dp> class neighb_;
- // Super type declaration.
- template <typename dpoint>
- struct set_super_type< neighb_<dpoint> >
+ // Super type.
+ template <typename Dp>
+ struct super_trait_< neighb_<Dp> >
{
- typedef neighb_<dpoint> self_t;
- typedef neighborhood_entry<self_t> ret;
+ typedef neighb_<Dp> current__;
+ typedef Neighborhood<current__> ret;
};
- /// Virtual types associated to oln::neighb_<dpoint>.
- template <typename dpoint>
- struct vtypes< neighb_<dpoint> >
+ /// Virtual types.
+ template <typename Dp>
+ struct vtypes< neighb_<Dp> >
{
- typedef oln_vtype(dpoint, grid) grid_type;
+ typedef stc_type(Dp, grid) grid;
};
- struct FIXME_ERR;
+ /// Generic classical neighborhood class.
-
- /// Abstract forward dpoint iterator class.
- template <typename dpoint>
- class neighb_ : public neighborhood_entry< neighb_<dpoint> >,
- private mlc::assert_< mlc_is_a(dpoint, abstract::dpoint), FIXME_ERR >
+ template <typename Dp>
+ class neighb_ : public Neighborhood< neighb_<Dp> >,
+ public internal::dpoints_impl_<Dp>
{
- typedef neighb_<dpoint> self_t;
- typedef neighborhood_entry<self_t> super_t;
-
public:
neighb_();
- neighb_<dpoint>& add(const dpoint& dp);
-
- template <typename D>
- neighb_<dpoint>& add(const abstract::dpoint<D>& dp);
-
- unsigned card() const;
-
- dpoint dp(unsigned i) const;
-
- // void print(std::ostream& ostr) const;
- // friend std::ostream& operator<<(std::ostream& ostr, const
neighb_<dpoint>& nbh);
+ neighb_<Dp>& take(const Dp& dp);
- protected:
-
- std::set<dpoint> s_;
- std::vector<dpoint> v_;
-
- void update_();
-
- }; // end of class oln::neighb_<dpoint>
+ }; // end of class oln::neighb_<Dp>
# ifndef OLN_INCLUDE_ONLY
-
- template <typename dpoint>
- neighb_<dpoint>::neighb_()
+ template <typename Dp>
+ neighb_<Dp>::neighb_()
{
}
- template <typename dpoint>
- neighb_<dpoint>& neighb_<dpoint>::add(const dpoint& dp)
+ template <typename Dp>
+ neighb_<Dp>& neighb_<Dp>::take(const Dp& dp)
{
- s_.insert(dp);
- s_.insert(-dp);
- update_();
+ this->take_( dp);
+ this->take_(-dp);
return *this;
}
- template <typename dpoint>
- template <typename D>
- neighb_<dpoint>& neighb_<dpoint>::add(const
abstract::dpoint<D>& dp)
- {
- return this->add(dp.exact());
- }
-
- template <typename dpoint>
- unsigned neighb_<dpoint>::card() const
- {
- return v_.size();
- }
-
- template <typename dpoint>
- dpoint neighb_<dpoint>::dp(unsigned i) const
- {
- precondition(i < v_.size());
- return v_[i];
- }
-
- template <typename dpoint>
- void neighb_<dpoint>::update_()
- {
- v_.clear();
- std::copy(s_.begin(), s_.end(),
- std::back_inserter(v_));
- }
-
# endif
Index: oln/core/gen/window.hh
--- oln/core/gen/window.hh (revision 854)
+++ oln/core/gen/window.hh (working copy)
@@ -1,5 +1,4 @@
-// Copyright (C) 2001, 2003, 2004, 2005, 2006 EPITA Research and
-// Development Laboratory
+// 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
@@ -29,123 +28,81 @@
#ifndef OLN_CORE_GEN_WINDOW_HH
# define OLN_CORE_GEN_WINDOW_HH
-# include <set>
-# include <vector>
-# include <mlc/assert.hh>
-# include <oln/core/abstract/dpoint.hh>
-# include <oln/core/abstract/window.hh>
+# include <oln/core/internal/dpoints_impl.hh>
+# include <oln/core/concept/window.hh>
namespace oln
{
+
// Fwd decl.
- template <typename dpoint> class window_;
+ template <typename Dp> class window_;
- template <typename dpoint>
- struct set_super_type< window_<dpoint> >
+ // Super type.
+ template <typename Dp>
+ struct super_trait_< window_<Dp> >
{
- typedef abstract::window< window_<dpoint> > ret;
+ typedef window_<Dp> current__;
+ typedef Window<current__> ret;
};
- template <typename dpoint>
- struct vtypes< window_<dpoint> >
+ /// Virtual types.
+ template <typename Dp>
+ struct vtypes< window_<Dp> >
{
- typedef oln_vtype(dpoint, grid) grid_type;
+ typedef stc_type(Dp, grid) grid;
};
- /// Abstract forward dpoint iterator class.
- template <typename dpoint>
- class window_ : public abstract::window< window_<dpoint> >,
- private mlc::assert_< mlc_is_a(dpoint, abstract::dpoint) >
- {
- typedef window_<dpoint> self_t;
+ /// Generic classical windoworhood class.
+ template <typename Dp>
+ class window_ : public Window< window_<Dp> >,
+ public internal::dpoints_impl_<Dp>
+ {
public:
window_();
- window_<dpoint>& add(const dpoint& dp);
-
- template <typename D>
- window_<dpoint>& add(const abstract::dpoint<D>& dp);
-
- dpoint dp(unsigned i) const;
-
- unsigned card() const;
+ window_<Dp>& take(const Dp& dp);
- bool impl_is_valid() const;
+ window_<Dp> impl_op_unary_minus_() const;
- protected:
+ }; // end of class oln::window_<Dp>
- std::set<dpoint> s_;
- std::vector<dpoint> v_;
-
- void update_();
-
- }; // end of class oln::window_<dpoint>
# ifndef OLN_INCLUDE_ONLY
- template <typename dpoint>
- window_<dpoint>::window_()
+ template <typename Dp>
+ window_<Dp>::window_()
{
}
- template <typename dpoint>
- window_<dpoint>&
- window_<dpoint>::add(const dpoint& dp)
+ template <typename Dp>
+ window_<Dp>&
+ window_<Dp>::take(const Dp& dp)
{
- s_.insert(dp);
- update_();
+ this->take_( dp);
return *this;
}
- template <typename dpoint>
- template <typename D>
- window_<dpoint>&
- window_<dpoint>::add(const abstract::dpoint<D>& dp)
- {
- return this->add(dp.exact());
- }
-
- template <typename dpoint>
- unsigned
- window_<dpoint>::card() const
- {
- return v_.size();
- }
-
- template <typename dpoint>
- dpoint
- window_<dpoint>::dp(unsigned i) const
- {
- precondition(i < v_.size());
- return v_[i];
- }
-
- template <typename dpoint>
- bool
- window_<dpoint>::impl_is_valid() const
- {
- return v_.size() != 0;
- }
-
- template <typename dpoint>
- void
- window_<dpoint>::update_()
- {
- v_.clear();
- std::copy(s_.begin(), s_.end(),
- std::back_inserter(v_));
+ template <typename Dp>
+ window_<Dp>
+ window_<Dp>::impl_op_unary_minus_() const
+ {
+ window_<Dp> tmp;
+ for (unsigned i = 0; i < this->size(); ++i)
+ tmp.take(- this->v_[i]);
+ return tmp;
}
# endif
+
} // end of namespace oln
Index: oln/core/internal/dpoints_impl.hh
--- oln/core/internal/dpoints_impl.hh (revision 854)
+++ oln/core/internal/dpoints_impl.hh (working copy)
@@ -1,4 +1,4 @@
-// Copyright (C) 2001, 2003, 2004, 2005, 2006 EPITA Research and
+// Copyright (C) 2001, 2003, 2004, 2005, 2006, 2007 EPITA Research and
// Development Laboratory
//
// This file is part of the Olena Library. This library is free
@@ -26,127 +26,104 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef OLN_CORE_GEN_WINDOW_HH
-# define OLN_CORE_GEN_WINDOW_HH
+#ifndef OLN_CORE_INTERNAL_DPOINTS_IMPL_HH
+# define OLN_CORE_INTERNAL_DPOINTS_IMPL_HH
# include <set>
# include <vector>
-# include <mlc/assert.hh>
-# include <oln/core/abstract/dpoint.hh>
-# include <oln/core/abstract/window.hh>
+# include <iterator>
+# include <oln/core/concept/dpoint.hh>
namespace oln
{
- // Fwd decl.
- template <typename dpoint> class window_;
-
-
- template <typename dpoint>
- struct set_super_type< window_<dpoint> >
- {
- typedef abstract::window< window_<dpoint> > ret;
- };
-
-
- template <typename dpoint>
- struct vtypes< window_<dpoint> >
+ namespace internal
{
- typedef oln_vtype(dpoint, grid) grid_type;
- };
+ /// Implementation for classes storing a set of dpoints.
- /// Abstract forward dpoint iterator class.
- template <typename dpoint>
- class window_ : public abstract::window< window_<dpoint> >,
- private mlc::assert_< mlc_is_a(dpoint, abstract::dpoint) >
+ template <typename Dp>
+ class dpoints_impl_
+ : private mlc::assert_< mlc_is_a(Dp, Dpoint) >
{
- typedef window_<dpoint> self_t;
-
public:
- window_();
-
- window_<dpoint>& add(const dpoint& dp);
-
- template <typename D>
- window_<dpoint>& add(const abstract::dpoint<D>& dp);
+ unsigned size() const;
+ const Dp& operator[](unsigned i) const;
+ const std::vector<Dp>& dpoints() const;
- dpoint dp(unsigned i) const;
-
- unsigned card() const;
+ protected:
- bool impl_is_valid() const;
+ dpoints_impl_();
+ void take_(const Dp& dp);
- protected:
+ std::vector<Dp> v_;
- std::set<dpoint> s_;
- std::vector<dpoint> v_;
+ private:
void update_();
+ std::set<Dp> s_;
- }; // end of class oln::window_<dpoint>
+ }; // end of class oln::internal::dpoints_impl_<Dp>
# ifndef OLN_INCLUDE_ONLY
- template <typename dpoint>
- window_<dpoint>::window_()
- {
- }
+ // public:
- template <typename dpoint>
- window_<dpoint>&
- window_<dpoint>::add(const dpoint& dp)
+ template <typename Dp>
+ unsigned
+ dpoints_impl_<Dp>::size() const
{
- s_.insert(dp);
- update_();
- return *this;
+ return v_.size();
}
- template <typename dpoint>
- template <typename D>
- window_<dpoint>&
- window_<dpoint>::add(const abstract::dpoint<D>& dp)
+ template <typename Dp>
+ const Dp&
+ dpoints_impl_<Dp>::operator[](unsigned i) const
{
- return this->add(dp.exact());
+ precondition(i < v_.size());
+ return v_[i];
}
- template <typename dpoint>
- unsigned
- window_<dpoint>::card() const
+ template <typename Dp>
+ const std::vector<Dp>&
+ dpoints_impl_<Dp>::dpoints() const
{
- return v_.size();
+ return v_;
}
- template <typename dpoint>
- dpoint
- window_<dpoint>::dp(unsigned i) const
+ // protected:
+
+ template <typename Dp>
+ dpoints_impl_<Dp>::dpoints_impl_()
{
- precondition(i < v_.size());
- return v_[i];
}
- template <typename dpoint>
- bool
- window_<dpoint>::impl_is_valid() const
+ template <typename Dp>
+ void
+ dpoints_impl_<Dp>::take_(const Dp& dp)
{
- return v_.size() != 0;
+ s_.insert(dp);
+ update_();
}
- template <typename dpoint>
+ // private:
+
+ template <typename Dp>
void
- window_<dpoint>::update_()
+ dpoints_impl_<Dp>::update_()
{
v_.clear();
- std::copy(s_.begin(), s_.end(),
- std::back_inserter(v_));
+ std::copy(s_.begin(), s_.end(), std::back_inserter(v_));
}
# endif
+ } // end of namespace oln::internal
+
} // end of namespace oln
-#endif // ! OLN_CORE_GEN_WINDOW_HH
+#endif // ! OLN_CORE_INTERNAL_DPOINTS_IMPL_HH
Index: oln/core/internal/image_selectors.hh
--- oln/core/internal/image_selectors.hh (revision 854)
+++ oln/core/internal/image_selectors.hh (working copy)
@@ -102,7 +102,7 @@
// FIXME: ...
template <typename Exact>
- struct default_case_< Image_pw_accessibility, Exact >
+ struct case_< Image_pw_accessibility, Exact, 3 >
:
where_< mlc::eq_< stc_get_type(psite), stc_get_type(point) > >
{
Index: oln/core/internal/dpoint_base.hh
--- oln/core/internal/dpoint_base.hh (revision 854)
+++ oln/core/internal/dpoint_base.hh (working copy)
@@ -31,6 +31,7 @@
# include <xtd/vec.hh>
# include <mlc/int.hh>
+# include <oln/core/internal/point_base.hh>
# include <oln/core/concept/dpoint.hh>
Index: oln/core/internal/image_base.hh
--- oln/core/internal/image_base.hh (revision 854)
+++ oln/core/internal/image_base.hh (working copy)
@@ -33,6 +33,7 @@
# include <oln/core/internal/utils.hh>
# include <oln/core/gen/box.hh>
# include <oln/core/gen/image_pset_piter.hh>
+# include <oln/core/gen/dpoints_piter.hh>
@@ -44,7 +45,10 @@
namespace internal
{
template <typename Exact> struct image_base_;
+
template <typename Exact> struct primitive_image_;
+ template <typename Exact> struct plain_primitive_image_;
+
template <typename Exact> struct image_morpher_;
template <typename Exact> struct single_image_morpher_;
template <typename Exact> struct multiple_image_morpher_;
@@ -66,6 +70,12 @@
};
template <typename Exact>
+ struct super_trait_< internal::plain_primitive_image_<Exact> >
+ {
+ typedef internal::primitive_image_<Exact> ret;
+ };
+
+ template <typename Exact>
struct super_trait_< internal::image_morpher_<Exact> >
{
typedef internal::image_base_<Exact> ret;
@@ -100,12 +110,8 @@
// FIXME: Uncomment below!
// typedef stc::abstract output;
- typedef stc::abstract data;
- // FIXME: Temporary hack:
- typedef mlc::none qiter;
- typedef mlc::none fwd_qiter;
- typedef mlc::none bkd_qiter;
+ typedef stc::abstract data;
// Deferred.
@@ -119,8 +125,7 @@
typedef stc::final< stc_type(point__, grid) > grid;
typedef stc::final< typename pset__::fwd_piter > fwd_piter;
typedef stc::final< typename pset__::bkd_piter > bkd_piter;
- typedef stc::final< fwd_piter > piter;
-
+ typedef fwd_piter piter;
};
@@ -130,6 +135,17 @@
};
template <typename Exact>
+ struct vtypes< internal::plain_primitive_image_<Exact> >
+ {
+ typedef stc_deferred(point) point__;
+
+ typedef stc::final< point__ > psite;
+ typedef stc::final< dpoints_fwd_piter_<point__> > fwd_qiter;
+ typedef stc::final< dpoints_bkd_piter_<point__> > bkd_qiter;
+ typedef fwd_qiter qiter;
+ };
+
+ template <typename Exact>
struct vtypes< internal::image_morpher_<Exact> >
{
typedef stc::abstract delegatee;
@@ -185,6 +201,16 @@
};
+ /// plain_primitive_image_<Exact>
+
+ template <typename Exact>
+ class plain_primitive_image_ : public primitive_image_<Exact>
+ {
+ protected:
+ plain_primitive_image_();
+ };
+
+
/// image_morpher_<Exact>
template <typename Exact>
@@ -261,6 +287,13 @@
{
}
+ /// plain_primitive_image_<Exact>
+
+ template <typename Exact>
+ plain_primitive_image_<Exact>::plain_primitive_image_()
+ {
+ }
+
// image_morpher_<Exact>
template <typename Exact>