* mln/core/box_runstart_piter.hh,
* mln/core/dpsites_piter.hh,
* mln/core/image/complex_window_piter.hh: Add new init_() member.
* mln/core/image/graph_elt_mixed_neighborhood.hh,
* mln/core/image/graph_elt_mixed_window.hh,
* mln/core/mixed_neighb.hh: New.
* mln/core/image/graph_elt_neighborhood.hh,
* mln/core/image/graph_elt_window.hh: Get rid of a template
parameter.
* mln/core/image/graph_window_piter.hh: Add a selector for
do_start_() implementation.
* mln/core/image/vertex_image.hh: Add a new include.
* mln/core/internal/neighb_base.hh: New neighborhood base class.
* mln/core/internal/neighb_niter_base.hh: New neiborhood iterator
base class.
* mln/core/internal/neighb_niter_impl.hh: Add a new specialization
for graph_elt_mixed_window.
* mln/core/neighb.hh: Make inherit from neighb_base.
* mln/core/window.hh: Update header.
* tests/core/image/vertex_and_edge_image.cc: Use a
graph_elt_mixed_window.
---
milena/ChangeLog | 36 +++
milena/mln/core/box_runstart_piter.hh | 12 +
milena/mln/core/dpsites_piter.hh | 17 ++-
milena/mln/core/image/complex_window_piter.hh | 30 +++
...hborhood.hh => graph_elt_mixed_neighborhood.hh} | 20 +-
...aph_elt_window.hh => graph_elt_mixed_window.hh} | 55 ++---
milena/mln/core/image/graph_elt_neighborhood.hh | 11 +-
milena/mln/core/image/graph_elt_window.hh | 58 ++---
milena/mln/core/image/graph_window_piter.hh | 123 +++++++++--
milena/mln/core/image/vertex_image.hh | 1 +
milena/mln/core/internal/neighb_base.hh | 128 +++++++++++
milena/mln/core/internal/neighb_niter_base.hh | 148 ++++++++++++
milena/mln/core/internal/neighb_niter_impl.hh | 24 ++-
milena/mln/core/mixed_neighb.hh | 240 ++++++++++++++++++++
milena/mln/core/neighb.hh | 218 +++---------------
milena/mln/core/window.hh | 3 +-
milena/tests/core/image/vertex_and_edge_image.cc | 3 +-
17 files changed, 824 insertions(+), 303 deletions(-)
copy milena/mln/core/image/{graph_elt_neighborhood.hh =>
graph_elt_mixed_neighborhood.hh} (76%)
copy milena/mln/core/image/{graph_elt_window.hh => graph_elt_mixed_window.hh} (73%)
create mode 100644 milena/mln/core/internal/neighb_base.hh
create mode 100644 milena/mln/core/internal/neighb_niter_base.hh
create mode 100644 milena/mln/core/mixed_neighb.hh
diff --git a/milena/ChangeLog b/milena/ChangeLog
index c996afc..d9a3461 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,5 +1,41 @@
2009-08-24 Guillaume Lazzara <lazzara(a)lrde.epita.fr>
+ Introduce mixed windows and neighborhood for graph images.
+
+ * mln/core/box_runstart_piter.hh,
+ * mln/core/dpsites_piter.hh,
+ * mln/core/image/complex_window_piter.hh: Add new init_() member.
+
+ * mln/core/image/graph_elt_mixed_neighborhood.hh,
+ * mln/core/image/graph_elt_mixed_window.hh,
+ * mln/core/mixed_neighb.hh: New.
+
+ * mln/core/image/graph_elt_neighborhood.hh,
+ * mln/core/image/graph_elt_window.hh: Get rid of a template
+ parameter.
+
+ * mln/core/image/graph_window_piter.hh: Add a selector for
+ do_start_() implementation.
+
+ * mln/core/image/vertex_image.hh: Add a new include.
+
+ * mln/core/internal/neighb_base.hh: New neighborhood base class.
+
+ * mln/core/internal/neighb_niter_base.hh: New neiborhood iterator
+ base class.
+
+ * mln/core/internal/neighb_niter_impl.hh: Add a new specialization
+ for graph_elt_mixed_window.
+
+ * mln/core/neighb.hh: Make inherit from neighb_base.
+
+ * mln/core/window.hh: Update header.
+
+ * tests/core/image/vertex_and_edge_image.cc: Use a
+ graph_elt_mixed_window.
+
+2009-08-24 Guillaume Lazzara <lazzara(a)lrde.epita.fr>
+
Small fixes in Milena.
* mln/canvas/labeling/blobs.hh,
diff --git a/milena/mln/core/box_runstart_piter.hh
b/milena/mln/core/box_runstart_piter.hh
index d58bc89..a777d1e 100644
--- a/milena/mln/core/box_runstart_piter.hh
+++ b/milena/mln/core/box_runstart_piter.hh
@@ -63,6 +63,9 @@ namespace mln
*/
box_runstart_piter(const box<P>& b);
+ /// Delayed initialization.
+ void init_(const box<P>& b);
+
box_runstart_piter();
/// Test the iterator validity.
@@ -101,9 +104,18 @@ namespace mln
inline
box_runstart_piter<P>::box_runstart_piter(const box<P>& b)
{
+ init_(b);
+ }
+
+ template <typename P>
+ inline
+ void
+ box_runstart_piter<P>::init_(const box<P>& b)
+ {
this->change_target(b);
}
+
template <typename P>
inline
bool
diff --git a/milena/mln/core/dpsites_piter.hh b/milena/mln/core/dpsites_piter.hh
index 0af9d9a..970fe0e 100644
--- a/milena/mln/core/dpsites_piter.hh
+++ b/milena/mln/core/dpsites_piter.hh
@@ -1,4 +1,5 @@
-// Copyright (C) 2007, 2008, 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2007, 2008, 2009 EPITA Research and Development
+// Laboratory (LRDE)
//
// This file is part of Olena.
//
@@ -56,6 +57,10 @@ namespace mln
template <typename P>
dpsites_fwd_piter(const V& v, const P& c);
+ /// Delayed initialization.
+ template <typename P>
+ void init_(const V& v, const P& c);
+
/// Constructor without argument.
dpsites_fwd_piter();
@@ -139,10 +144,20 @@ namespace mln
inline
dpsites_fwd_piter<V>::dpsites_fwd_piter(const V& v, const P& c)
{
+ init_(v, c);
+ }
+
+ template <typename V>
+ template <typename P>
+ inline
+ void
+ dpsites_fwd_piter<V>::init_(const V& v, const P& c)
+ {
this->change_target(v);
this->center_at(c);
}
+
template <typename V>
inline
bool
diff --git a/milena/mln/core/image/complex_window_piter.hh
b/milena/mln/core/image/complex_window_piter.hh
index 309f083..b723ec6 100644
--- a/milena/mln/core/image/complex_window_piter.hh
+++ b/milena/mln/core/image/complex_window_piter.hh
@@ -72,6 +72,10 @@ namespace mln
complex_window_fwd_piter(const Window<W>& win, const Pref& p_ref);
/// \}
+ /// Delayed initialization.
+ template <typename Pref>
+ void init_(const Window<W>& win, const Pref& p_ref);
+
/// Manipulation.
/// \{
/// Test if the iterator is valid.
@@ -138,6 +142,10 @@ namespace mln
complex_window_bkd_piter(const Window<W>& win, const Pref& p_ref);
/// \}
+ /// Delayed initialization.
+ template <typename Pref>
+ void init_(const Window<W>& win, const Pref& p_ref);
+
/// Manipulation.
/// \{
/// Test if the iterator is valid.
@@ -196,11 +204,22 @@ namespace mln
complex_window_fwd_piter<I, G, W>::complex_window_fwd_piter(const
Window<W>& win,
const Pref& p_ref)
{
+ init_(win, p_ref);
+ }
+
+ template <typename I, typename G, typename W>
+ template <typename Pref>
+ inline
+ void
+ complex_window_fwd_piter<I, G, W>::init_(const Window<W>& win,
+ const Pref& p_ref)
+ {
this->change_target(exact(win));
center_at(p_ref);
mln_postcondition(!this->is_valid());
}
+
template <typename I, typename G, typename W>
inline
bool
@@ -293,11 +312,22 @@ namespace mln
complex_window_bkd_piter<I, G, W>::complex_window_bkd_piter(const
Window<W>& win,
const Pref& p_ref)
{
+ init_(win, p_ref);
+ }
+
+ template <typename I, typename G, typename W>
+ template <typename Pref>
+ inline
+ void
+ complex_window_bkd_piter<I, G, W>::init_(const Window<W>& win,
+ const Pref& p_ref)
+ {
this->change_target(exact(win));
center_at(p_ref);
mln_postcondition(!this->is_valid());
}
+
template <typename I, typename G, typename W>
inline
bool
diff --git a/milena/mln/core/image/graph_elt_neighborhood.hh
b/milena/mln/core/image/graph_elt_mixed_neighborhood.hh
similarity index 76%
copy from milena/mln/core/image/graph_elt_neighborhood.hh
copy to milena/mln/core/image/graph_elt_mixed_neighborhood.hh
index a1a739f..40245ce 100644
--- a/milena/mln/core/image/graph_elt_neighborhood.hh
+++ b/milena/mln/core/image/graph_elt_mixed_neighborhood.hh
@@ -24,15 +24,15 @@
// exception does not however invalidate any other reasons why the
// executable file might be covered by the GNU General Public License.
-#ifndef MLN_CORE_IMAGE_GRAPH_ELT_NEIGHBORHOOD_HH
-# define MLN_CORE_IMAGE_GRAPH_ELT_NEIGHBORHOOD_HH
+#ifndef MLN_CORE_IMAGE_GRAPH_ELT_MIXED_NEIGHBORHOOD_HH
+# define MLN_CORE_IMAGE_GRAPH_ELT_MIXED_NEIGHBORHOOD_HH
/// \file
///
/// Definition of the elementary ``neighborhood'' on a graph.
# include <mln/core/neighb.hh>
-# include <mln/core/image/graph_elt_window.hh>
+# include <mln/core/image/graph_elt_mixed_window.hh>
namespace mln
@@ -44,13 +44,13 @@ namespace mln
/// \tparam S is a site set type.
/// \tparam S2 is the site set type of the neighbors.
//
- template <typename G, typename S, typename S2 = S>
- struct graph_elt_neighborhood
- : public neighb< graph_elt_window<G,S,S2> >
+ template <typename G, typename S, typename S2>
+ struct graph_elt_mixed_neighborhood
+ : public neighb< graph_elt_mixed_window<G,S,S2> >
{
- typedef neighb< graph_elt_window<G,S,S2> > super_;
+ typedef neighb< graph_elt_mixed_window<G,S,S2> > super_;
- graph_elt_neighborhood();
+ graph_elt_mixed_neighborhood();
};
@@ -60,7 +60,7 @@ namespace mln
template <typename G, typename S, typename S2>
inline
- graph_elt_neighborhood<G,S,S2>::graph_elt_neighborhood()
+ graph_elt_mixed_neighborhood<G,S,S2>::graph_elt_mixed_neighborhood()
{
}
@@ -69,4 +69,4 @@ namespace mln
}
-#endif // ! MLN_CORE_IMAGE_GRAPH_ELT_NEIGHBORHOOD_HH
+#endif // ! MLN_CORE_IMAGE_GRAPH_ELT_MIXED_NEIGHBORHOOD_HH
diff --git a/milena/mln/core/image/graph_elt_window.hh
b/milena/mln/core/image/graph_elt_mixed_window.hh
similarity index 73%
copy from milena/mln/core/image/graph_elt_window.hh
copy to milena/mln/core/image/graph_elt_mixed_window.hh
index 867a7bd..6ece878 100644
--- a/milena/mln/core/image/graph_elt_window.hh
+++ b/milena/mln/core/image/graph_elt_mixed_window.hh
@@ -1,5 +1,4 @@
-// Copyright (C) 2007, 2008, 2009 EPITA Research and Development
-// Laboratory (LRDE)
+// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
//
// This file is part of Olena.
//
@@ -24,12 +23,13 @@
// exception does not however invalidate any other reasons why the
// executable file might be covered by the GNU General Public License.
-#ifndef MLN_CORE_IMAGE_GRAPH_ELT_WINDOW_HH
-# define MLN_CORE_IMAGE_GRAPH_ELT_WINDOW_HH
+#ifndef MLN_CORE_IMAGE_GRAPH_ELT_MIXED_WINDOW_HH
+# define MLN_CORE_IMAGE_GRAPH_ELT_MIXED_WINDOW_HH
/// \file
///
-/// Definition of the elementary ``window'' on a graph.
+/// Definition of the elementary ``window'' on a graph where elements
+/// are in a different site set from the center's.
# include <mln/core/concept/window.hh>
# include <mln/core/internal/neighborhood_base.hh>
@@ -41,7 +41,7 @@ namespace mln
{
/// Forward declaration
- template <typename G, typename S, typename S2> class graph_elt_window;
+ template <typename G, typename S, typename S2> class graph_elt_mixed_window;
template <typename G, typename F> struct p_edges;
template <typename G, typename F> struct p_vertices;
namespace util
@@ -55,8 +55,8 @@ namespace mln
{
template <typename G, typename S, typename S2, typename E>
- struct neighborhood_impl<graph_elt_window<G,S,S2>,E>
- : public neighborhood_extra_impl<graph_elt_window<G,S,S2>,E>
+ struct neighborhood_impl<graph_elt_mixed_window<G,S,S2>,E>
+ : public neighborhood_extra_impl<graph_elt_mixed_window<G,S,S2>,E>
{
};
@@ -70,29 +70,10 @@ namespace mln
/// extracted.
//
template <typename G, typename S, typename S2>
- struct graph_window_iter_dispatch;
-
- template <typename G, typename F>
- struct graph_window_iter_dispatch<G, p_edges<G,F>, p_edges<G,F> >
- {
- typedef mln_edge_nbh_edge_fwd_iter(G) nbh_fwd_iter_;
- typedef mln_edge_nbh_edge_bkd_iter(G) nbh_bkd_iter_;
-
- typedef p_edges<G,F> target;
- };
-
- template <typename G, typename F>
- struct graph_window_iter_dispatch<G, p_vertices<G,F>, p_vertices<G,F>
>
- {
- typedef mln_vertex_nbh_vertex_fwd_iter(G) nbh_fwd_iter_;
- typedef mln_vertex_nbh_vertex_bkd_iter(G) nbh_bkd_iter_;
-
- typedef p_vertices<G,F> target;
- };
-
+ struct graph_mixed_window_iter_dispatch;
template <typename G, typename F, typename F2>
- struct graph_window_iter_dispatch<G, p_vertices<G,F>, p_edges<G,F2>
>
+ struct graph_mixed_window_iter_dispatch<G, p_vertices<G,F>,
p_edges<G,F2> >
{
typedef mln_vertex_nbh_edge_fwd_iter(G) nbh_fwd_iter_;
typedef mln_vertex_nbh_edge_bkd_iter(G) nbh_bkd_iter_;
@@ -108,7 +89,7 @@ namespace mln
{
template <typename G, typename S, typename S2>
- struct window_< mln::graph_elt_window<G,S,S2> >
+ struct window_< mln::graph_elt_mixed_window<G,S,S2> >
{
typedef trait::window::size::unknown size;
typedef trait::window::support::irregular support;
@@ -124,14 +105,14 @@ namespace mln
/// \p S2 is an image site set from where the neighbors are
/// extracted.
//
- template <typename G, typename S, typename S2 = S>
- class graph_elt_window
+ template <typename G, typename S, typename S2>
+ class graph_elt_mixed_window
: public graph_window_base<mln_result(S2::fun_t),
- graph_elt_window<G,S,S2> >,
- public internal::graph_window_iter_dispatch<G,S,S2>
+ graph_elt_mixed_window<G,S,S2> >,
+ public internal::graph_mixed_window_iter_dispatch<G,S,S2>
{
- typedef graph_elt_window<G,S,S2> self_;
- typedef internal::graph_window_iter_dispatch<G,S,S2> super_;
+ typedef graph_elt_mixed_window<G,S,S2> self_;
+ typedef internal::graph_mixed_window_iter_dispatch<G,S,S2> super_;
typedef typename super_::nbh_fwd_iter_ nbh_fwd_iter_;
typedef typename super_::nbh_bkd_iter_ nbh_bkd_iter_;
@@ -166,4 +147,4 @@ namespace mln
} // end of namespace mln
-#endif // ! MLN_CORE_IMAGE_GRAPH_ELT_WINDOW_HH
+#endif // ! MLN_CORE_IMAGE_GRAPH_ELT_MIXED_WINDOW_HH
diff --git a/milena/mln/core/image/graph_elt_neighborhood.hh
b/milena/mln/core/image/graph_elt_neighborhood.hh
index a1a739f..b946067 100644
--- a/milena/mln/core/image/graph_elt_neighborhood.hh
+++ b/milena/mln/core/image/graph_elt_neighborhood.hh
@@ -42,13 +42,12 @@ namespace mln
///
/// \tparam G is a graph type.
/// \tparam S is a site set type.
- /// \tparam S2 is the site set type of the neighbors.
//
- template <typename G, typename S, typename S2 = S>
+ template <typename G, typename S>
struct graph_elt_neighborhood
- : public neighb< graph_elt_window<G,S,S2> >
+ : public neighb< graph_elt_window<G,S> >
{
- typedef neighb< graph_elt_window<G,S,S2> > super_;
+ typedef neighb< graph_elt_window<G,S> > super_;
graph_elt_neighborhood();
};
@@ -58,9 +57,9 @@ namespace mln
# ifndef MLN_INCLUDE_ONLY
- template <typename G, typename S, typename S2>
+ template <typename G, typename S>
inline
- graph_elt_neighborhood<G,S,S2>::graph_elt_neighborhood()
+ graph_elt_neighborhood<G,S>::graph_elt_neighborhood()
{
}
diff --git a/milena/mln/core/image/graph_elt_window.hh
b/milena/mln/core/image/graph_elt_window.hh
index 867a7bd..b39c44e 100644
--- a/milena/mln/core/image/graph_elt_window.hh
+++ b/milena/mln/core/image/graph_elt_window.hh
@@ -41,7 +41,7 @@ namespace mln
{
/// Forward declaration
- template <typename G, typename S, typename S2> class graph_elt_window;
+ template <typename G, typename S> class graph_elt_window;
template <typename G, typename F> struct p_edges;
template <typename G, typename F> struct p_vertices;
namespace util
@@ -54,9 +54,9 @@ namespace mln
namespace internal
{
- template <typename G, typename S, typename S2, typename E>
- struct neighborhood_impl<graph_elt_window<G,S,S2>,E>
- : public neighborhood_extra_impl<graph_elt_window<G,S,S2>,E>
+ template <typename G, typename S, typename E>
+ struct neighborhood_impl<graph_elt_window<G,S>,E>
+ : public neighborhood_extra_impl<graph_elt_window<G,S>,E>
{
};
@@ -66,49 +66,32 @@ namespace mln
///
/// \p G is the graph type.
/// \p S is an image site set from where the center is extracted.
- /// \p S2 is an image site set from where the neighbors are
- /// extracted.
//
- template <typename G, typename S, typename S2>
+ template <typename G, typename S>
struct graph_window_iter_dispatch;
template <typename G, typename F>
- struct graph_window_iter_dispatch<G, p_edges<G,F>, p_edges<G,F> >
+ struct graph_window_iter_dispatch<G, p_edges<G,F> >
{
typedef mln_edge_nbh_edge_fwd_iter(G) nbh_fwd_iter_;
typedef mln_edge_nbh_edge_bkd_iter(G) nbh_bkd_iter_;
-
- typedef p_edges<G,F> target;
};
template <typename G, typename F>
- struct graph_window_iter_dispatch<G, p_vertices<G,F>, p_vertices<G,F>
>
+ struct graph_window_iter_dispatch<G, p_vertices<G,F> >
{
typedef mln_vertex_nbh_vertex_fwd_iter(G) nbh_fwd_iter_;
typedef mln_vertex_nbh_vertex_bkd_iter(G) nbh_bkd_iter_;
-
- typedef p_vertices<G,F> target;
};
-
- template <typename G, typename F, typename F2>
- struct graph_window_iter_dispatch<G, p_vertices<G,F>, p_edges<G,F2>
>
- {
- typedef mln_vertex_nbh_edge_fwd_iter(G) nbh_fwd_iter_;
- typedef mln_vertex_nbh_edge_bkd_iter(G) nbh_bkd_iter_;
-
- typedef p_edges<G,F2> target;
- };
-
-
} // end of namespace mln::internal
namespace trait
{
- template <typename G, typename S, typename S2>
- struct window_< mln::graph_elt_window<G,S,S2> >
+ template <typename G, typename S>
+ struct window_< mln::graph_elt_window<G,S> >
{
typedef trait::window::size::unknown size;
typedef trait::window::support::irregular support;
@@ -124,14 +107,14 @@ namespace mln
/// \p S2 is an image site set from where the neighbors are
/// extracted.
//
- template <typename G, typename S, typename S2 = S>
+ template <typename G, typename S>
class graph_elt_window
- : public graph_window_base<mln_result(S2::fun_t),
- graph_elt_window<G,S,S2> >,
- public internal::graph_window_iter_dispatch<G,S,S2>
+ : public graph_window_base<mln_result(S::fun_t),
+ graph_elt_window<G,S> >,
+ public internal::graph_window_iter_dispatch<G,S>
{
- typedef graph_elt_window<G,S,S2> self_;
- typedef internal::graph_window_iter_dispatch<G,S,S2> super_;
+ typedef graph_elt_window<G,S> self_;
+ typedef internal::graph_window_iter_dispatch<G,S> super_;
typedef typename super_::nbh_fwd_iter_ nbh_fwd_iter_;
typedef typename super_::nbh_bkd_iter_ nbh_bkd_iter_;
@@ -139,23 +122,24 @@ namespace mln
public:
/// Associated types.
/// \{
- typedef typename super_::target target;
+ typedef S target;
+
/// The type of psite corresponding to the window.
- typedef mln_psite(target) psite;
+ typedef mln_psite(S) psite;
/// Type of the window center element.
typedef mln_psite(S) center_t;
/// Type of the graph element pointed by this iterator.
- typedef mln_graph_element(target) graph_element;
+ typedef mln_graph_element(S) graph_element;
/// Site_Iterator type to browse the psites of the window
/// w.r.t. the ordering of vertices.
- typedef graph_window_piter<target,self_,nbh_fwd_iter_> fwd_qiter;
+ typedef graph_window_piter<S,self_,nbh_fwd_iter_> fwd_qiter;
/// Site_Iterator type to browse the psites of the window
/// w.r.t. the reverse ordering of vertices.
- typedef graph_window_piter<target,self_,nbh_bkd_iter_> bkd_qiter;
+ typedef graph_window_piter<S,self_,nbh_bkd_iter_> bkd_qiter;
/// The default qiter type.
typedef fwd_qiter qiter;
diff --git a/milena/mln/core/image/graph_window_piter.hh
b/milena/mln/core/image/graph_window_piter.hh
index 7812767..8ea77db 100644
--- a/milena/mln/core/image/graph_window_piter.hh
+++ b/milena/mln/core/image/graph_window_piter.hh
@@ -30,6 +30,9 @@
/// \file
///
/// Definition of a graph element iterator on a graph window.
+///
+/// \fixme Split into graph_window_piter, graph_mixed_window_piter and
+/// graph_window_piter_base.
# include <mln/core/concept/site_set.hh>
# include <mln/core/concept/window.hh>
@@ -42,6 +45,59 @@ namespace mln
// Forward declaration.
template <typename S, typename I> class p_graph_piter;
+
+ namespace internal
+ {
+
+ /// The window center and the window elements are part of
+ /// different site sets.
+ template <typename C, typename P, typename E>
+ struct impl_selector
+ {
+ E& exact()
+ {
+ return internal::force_exact<E>(*this);
+ }
+
+ void do_start_()
+ {
+ exact().iter_.start();
+ // Nothing else to do. A pointer to the window element's site
+ // set has been already stored in the constructor.
+ }
+
+ };
+
+ /// The window center and the window elements are part of the same
+ /// site set.
+ template <typename C, typename E>
+ struct impl_selector<C,C,E>
+ {
+ E& exact()
+ {
+ return internal::force_exact<E>(*this);
+ }
+
+ void do_start_()
+ {
+ exact().iter_.start();
+
+ // We need to store a pointer on the site set of the window
+ // center.
+ // We cannot do this in the constructor since the center may
+ // not be initialized.
+ // Here we suppose that if we start this iterator, the
+ // potential iterator used as center has been started just
+ // before calling this method.
+ //
+ exact().change_target_site_set(exact().center().site_set());
+ }
+
+ };
+
+ } // end of namespace mln::internal
+
+
/// Forward iterator on line graph window.
///
/// \tparam S is the site set type.
@@ -52,11 +108,17 @@ namespace mln
class graph_window_piter
: public internal::site_relative_iterator_base< W,
graph_window_piter<S,W,I>,
- typename W::center_t >
+ typename W::center_t >,
+ public internal::impl_selector<typename W::center_t, mln_psite(W),
+ graph_window_piter<S,W,I> >
{
typedef graph_window_piter<S,W,I> self_;
typedef
internal::site_relative_iterator_base<W,self_,mln_psite(S)> super_;
+ typedef
+ internal::impl_selector<typename W::center_t, mln_psite(W),
+ graph_window_piter<S,W,I> > super_impl_;
+
public:
/// Associated types
@@ -103,6 +165,17 @@ namespace mln
const Pref& p_ref);
/// \}
+ /// Delayed initialization.
+ /// \{
+ template <typename Pref>
+ void init_(const Window<W>& win, const Pref& p_ref);
+
+ template <typename Pref>
+ void init_(const Window<W>& win,
+ const Site_Set<S>& target_site_set,
+ const Pref& p_ref);
+ /// \}
+
/// Manipulation.
/// \{
/// Test if the iterator is valid.
@@ -110,8 +183,6 @@ namespace mln
/// Invalidate the iterator.
void invalidate_();
- /// Start an iteration.
- void do_start_();
/// Go to the next point.
void do_next_();
@@ -139,6 +210,11 @@ namespace mln
void change_target_site_set(const S& s);
const S& target_site_set() const;
+ using super_impl_::do_start_;
+
+ friend class internal::impl_selector<typename W::center_t, mln_psite(W),
+ graph_window_piter<S,W,I> > ;
+
private:
I iter_;
const S* s_;
@@ -166,12 +242,7 @@ namespace mln
// Center and neighbor sites have the same type and belong to
// the same site set.
mlc_is(center_t, mln_psite(W))::check();
-
- this->center_at(p_ref);
- this->change_target(exact(win));
- change_target_site_set(this->center().site_set());
-
- mln_postcondition(!this->is_valid());
+ init_(win, p_ref);
}
@@ -186,14 +257,36 @@ namespace mln
// Center and neighbors sites do not have the same type and do
// not belong to the same site set.
mlc_is_not(center_t, mln_psite(W))::check();
+ init_(win, target_site_set, p_ref);
+ }
+ template <typename S, typename W, typename I>
+ template <typename Pref>
+ inline
+ void
+ graph_window_piter<S,W,I>::init_(const Window<W>& win,
+ const Pref& p_ref)
+ {
this->center_at(p_ref);
this->change_target(exact(win));
- change_target_site_set(exact(target_site_set));
mln_postcondition(!this->is_valid());
}
+ template <typename S, typename W, typename I>
+ template <typename Pref>
+ inline
+ void
+ graph_window_piter<S,W,I>::init_(const Window<W>& win,
+ const Site_Set<S>& target_site_set,
+ const Pref& p_ref)
+ {
+ this->center_at(p_ref);
+ this->change_target(exact(win));
+ change_target_site_set(exact(target_site_set));
+ mln_postcondition(!this->is_valid());
+ }
+
template <typename S, typename W, typename I>
inline
@@ -214,14 +307,6 @@ namespace mln
template <typename S, typename W, typename I>
inline
void
- graph_window_piter<S,W,I>::do_start_()
- {
- iter_.start();
- }
-
- template <typename S, typename W, typename I>
- inline
- void
graph_window_piter<S,W,I>::do_next_()
{
iter_.next();
@@ -234,7 +319,6 @@ namespace mln
graph_window_piter<S, W, I>::center_at_(const Pref& c)
{
iter_.center_at(c.p_hook_());
- //FIXME: should we update target site set?
}
template <typename S, typename W, typename I>
@@ -244,7 +328,6 @@ namespace mln
graph_window_piter<S, W, I>::center_at_(const p_graph_piter<S2, I2>&
c)
{
iter_.center_at(c.hook_elt_());
- //FIXME: should we update target site set?
}
template <typename S, typename W, typename I>
diff --git a/milena/mln/core/image/vertex_image.hh
b/milena/mln/core/image/vertex_image.hh
index fd7d2eb..3ce7ed5 100644
--- a/milena/mln/core/image/vertex_image.hh
+++ b/milena/mln/core/image/vertex_image.hh
@@ -33,6 +33,7 @@
# include <mln/core/concept/graph.hh>
# include <mln/core/image/graph_elt_window.hh>
# include <mln/core/image/graph_elt_neighborhood.hh>
+# include <mln/core/image/graph_elt_mixed_neighborhood.hh>
# include <mln/core/site_set/p_vertices.hh>
# include <mln/pw/internal/image_base.hh>
# include <mln/fun/i2v/array.hh>
diff --git a/milena/mln/core/internal/neighb_base.hh
b/milena/mln/core/internal/neighb_base.hh
new file mode 100644
index 0000000..bfb499a
--- /dev/null
+++ b/milena/mln/core/internal/neighb_base.hh
@@ -0,0 +1,128 @@
+// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
+//
+// This file is part of Olena.
+//
+// Olena is free software: you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free
+// Software Foundation, version 2 of the License.
+//
+// Olena 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 Olena. If not, see <http://www.gnu.org/licenses/>.
+//
+// As a special exception, you may use this file as part of a free
+// software project 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 MLN_CORE_INTERNAL_NEIGHB_BASE_HH
+# define MLN_CORE_INTERNAL_NEIGHB_BASE_HH
+
+/// \file
+///
+/// Base implementation for neighborhood classes.
+
+# include <mln/core/internal/neighborhood_base.hh>
+# include <mln/core/internal/site_relative_iterator_base.hh>
+# include <mln/core/internal/neighb_niter_impl.hh>
+
+
+namespace mln
+{
+
+ namespace internal
+ {
+
+
+ /// Adapter class from window to neighborhood.
+ ///
+ /// \tparam W The underlying window type.
+ /// \tparam E The exact neighborhood type.
+ //
+ template <typename W, typename E>
+ class neighb_base
+ : public internal::neighborhood_base< W, E >,
+ private mlc_is_a(W, Window)::check_t
+ {
+ public:
+
+ /// Constructor without argument.
+ neighb_base();
+
+ /// Constructor from a window \p win.
+ neighb_base(const W& win);
+
+ /// Get the corresponding window.
+ const W& win() const;
+
+ /// Change the corresponding window.
+ void change_window(const W& new_win);
+
+
+ /// \internal Hook to the window.
+ W& hook_win_();
+
+ private:
+
+ W win_;
+ };
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ // neighb<W,E>
+
+ template <typename W, typename E>
+ inline
+ neighb_base<W,E>::neighb_base()
+ {
+ }
+
+ template <typename W, typename E>
+ inline
+ neighb_base<W,E>::neighb_base(const W& win)
+ {
+ change_window(win);
+ }
+
+ template <typename W, typename E>
+ inline
+ const W&
+ neighb_base<W,E>::win() const
+ {
+ return win_;
+ }
+
+ template <typename W, typename E>
+ inline
+ void
+ neighb_base<W,E>::change_window(const W& new_win)
+ {
+ mln_precondition(new_win.is_neighbable_());
+ win_ = new_win;
+ }
+
+ template <typename W, typename E>
+ inline
+ W&
+ neighb_base<W,E>::hook_win_()
+ {
+ return win_;
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::internal
+
+} // end of namespace mln
+
+
+#endif // ! MLN_CORE_INTERNAL_NEIGHB_BASE_HH
diff --git a/milena/mln/core/internal/neighb_niter_base.hh
b/milena/mln/core/internal/neighb_niter_base.hh
new file mode 100644
index 0000000..6aba054
--- /dev/null
+++ b/milena/mln/core/internal/neighb_niter_base.hh
@@ -0,0 +1,148 @@
+// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
+//
+// This file is part of Olena.
+//
+// Olena is free software: you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free
+// Software Foundation, version 2 of the License.
+//
+// Olena 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 Olena. If not, see <http://www.gnu.org/licenses/>.
+//
+// As a special exception, you may use this file as part of a free
+// software project 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 MLN_CORE_INTERNAL_NEIGHB_NITER_BASE_HH
+# define MLN_CORE_INTERNAL_NEIGHB_NITER_BASE_HH
+
+/// \file
+///
+/// Base implementation for neighborhood iterators.
+
+namespace mln
+{
+
+ namespace internal
+ {
+
+ // neighb_niter_base<W,I,E>
+
+ template <typename W, typename N, typename I, typename E>
+ class neighb_niter_base
+ : public internal::site_relative_iterator_base< N,
+ E,
+ mln_psite(N) >,
+ public internal::neighb_niter_impl<W,E>
+ {
+ public:
+
+ /// Constructor without argument.
+ neighb_niter_base();
+
+ template <typename P>
+ neighb_niter_base(const N& nbh, const P& c);
+
+ /// Test the iterator validity.
+ bool is_valid_() const;
+
+ /// Invalidate the iterator.
+ void invalidate_();
+
+ /// Start an iteration.
+ void do_start_();
+
+ /// Go to the next point.
+ void do_next_();
+
+ /// Compute the current psite.
+ mln_psite(W) compute_p_() const;
+
+ protected:
+
+ I i_;
+ };
+
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+
+ // neighb_niter_base<W,N,I,E>
+
+ template <typename W, typename N, typename I, typename E>
+ inline
+ neighb_niter_base<W,N,I,E>::neighb_niter_base()
+ {
+ }
+
+ template <typename W, typename N, typename I, typename E>
+ template <typename P>
+ inline
+ neighb_niter_base<W,N,I,E>::neighb_niter_base(const N& nbh, const P&
c)
+ {
+ this->change_target(nbh);
+ this->center_at(c);
+
+ }
+
+ template <typename W, typename N, typename I, typename E>
+ inline
+ bool
+ neighb_niter_base<W,N,I,E>::is_valid_() const
+ {
+ return i_.is_valid();
+ }
+
+ template <typename W, typename N, typename I, typename E>
+ inline
+ void
+ neighb_niter_base<W,N,I,E>::invalidate_()
+ {
+ i_.invalidate();
+ }
+
+ template <typename W, typename N, typename I, typename E>
+ inline
+ void
+ neighb_niter_base<W,N,I,E>::do_start_()
+ {
+ i_.start();
+ }
+
+ template <typename W, typename N, typename I, typename E>
+ inline
+ void
+ neighb_niter_base<W,N,I,E>::do_next_()
+ {
+ i_.next();
+ }
+
+ template <typename W, typename N, typename I, typename E>
+ inline
+ mln_psite(W)
+ neighb_niter_base<W,N,I,E>::compute_p_() const
+ {
+ return i_.compute_p_();
+ }
+
+
+# endif // ! MLN_INCLUDE_ONLY
+
+
+ } // end of namespace mln::internal
+
+} // end of namespace mln
+
+
+#endif // ! MLN_CORE_INTERNAL_NEIGHB_NITER_BASE_HH
diff --git a/milena/mln/core/internal/neighb_niter_impl.hh
b/milena/mln/core/internal/neighb_niter_impl.hh
index ea44822..f2c8ee0 100644
--- a/milena/mln/core/internal/neighb_niter_impl.hh
+++ b/milena/mln/core/internal/neighb_niter_impl.hh
@@ -1,4 +1,5 @@
-// Copyright (C) 2008, 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2008, 2009 EPITA Research and Development Laboratory
+// (LRDE)
//
// This file is part of Olena.
//
@@ -39,7 +40,8 @@ namespace mln
// Forward declaration.
template <typename P, typename W> class graph_window_base;
- template <typename G, typename F, typename Q> class graph_elt_window;
+ template <typename G, typename S> class graph_elt_window;
+ template <typename G, typename S, typename S2> class graph_elt_mixed_window;
template <typename G, typename F, typename I> class graph_elt_window_if;
template <typename G, typename F> class line_graph_elt_window;
namespace util
@@ -124,10 +126,10 @@ namespace mln
/// Add more implementation for neighborhoods made from a
/// graph_window_piter.
- template <typename G, typename S, typename Q, typename E>
- struct neighb_niter_impl<graph_elt_window<G,S,Q>, E>
+ template <typename G, typename S, typename E>
+ struct neighb_niter_impl<graph_elt_window<G,S>, E>
: public neighb_niter_impl< graph_window_base< mln_result(S::fun_t),
- graph_elt_window<G,S,Q> >,
+ graph_elt_window<G,S> >,
E >
{
@@ -157,6 +159,18 @@ namespace mln
};
+ /// Add more implementation for neighborhoods made from a
+ /// graph_window_piter.
+ template <typename G, typename S, typename S2, typename E>
+ struct neighb_niter_impl<graph_elt_mixed_window<G,S,S2>, E>
+ : public neighb_niter_impl< graph_window_base< mln_result(S2::fun_t),
+ graph_elt_mixed_window<G,S,S2> >,
+ E >
+ {
+
+ };
+
+
} // end of namespace mln::internal
} // end of namespace mln
diff --git a/milena/mln/core/mixed_neighb.hh b/milena/mln/core/mixed_neighb.hh
new file mode 100644
index 0000000..377bab1
--- /dev/null
+++ b/milena/mln/core/mixed_neighb.hh
@@ -0,0 +1,240 @@
+// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
+//
+// This file is part of Olena.
+//
+// Olena is free software: you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free
+// Software Foundation, version 2 of the License.
+//
+// Olena 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 Olena. If not, see <http://www.gnu.org/licenses/>.
+//
+// As a special exception, you may use this file as part of a free
+// software project 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 MLN_CORE_MIXED_NEIGHB_HH
+# define MLN_CORE_MIXED_NEIGHB_HH
+
+/// \file
+///
+/// Definition of a window-to-neighborhood adapter.
+///
+/// Works for windows and neighborhoods having the elements' site set
+/// different from the center's site set.
+///
+///
+/// \todo See if the impl of from_to is fine. What about removing the
+/// origin? etc.
+
+# include <mln/core/internal/neighb_base.hh>
+# include <mln/core/internal/neighb_niter_base.hh>
+# include <mln/core/internal/site_relative_iterator_base.hh>
+# include <mln/core/internal/neighb_niter_impl.hh>
+
+
+namespace mln
+{
+
+ // Forward declarations.
+ template <typename W> class mixed_neighb_fwd_niter;
+ template <typename W> class mixed_neighb_bkd_niter;
+ template <typename W> class mixed_neighb;
+
+
+ namespace convert
+ {
+
+ namespace over_load
+ {
+
+ template <typename W>
+ void
+ from_to_(const mln::mixed_neighb<W>& from, W& to);
+
+ template <typename W>
+ void
+ from_to_(const W& from, mln::mixed_neighb<W>& to);
+
+ } // end of namespace mln::convert::over_load
+
+ } // end of namespace mln::convert
+
+
+
+ /// Adapter class from window to neighborhood.
+
+ template <typename W>
+ class mixed_neighb
+ : public internal::neighb_base<W,mixed_neighb<W> >,
+ private mlc_is_a(W, Window)::check_t
+ {
+ typedef internal::neighb_base<W,mixed_neighb<W> > super_;
+
+ public:
+
+ /// Forward site iterator associated type.
+ typedef mixed_neighb_fwd_niter<W> fwd_niter;
+
+ /// Backward site iterator associated type.
+ typedef mixed_neighb_bkd_niter<W> bkd_niter;
+
+ /// Site iterator associated type.
+ typedef fwd_niter niter;
+
+
+ /// Constructor without argument.
+ mixed_neighb();
+
+ /// Constructor from a window \p win.
+ mixed_neighb(const W& win);
+
+ };
+
+
+ // mixed_neighb_fwd_niter<W>
+
+ template <typename W>
+ class mixed_neighb_fwd_niter
+ : public internal::neighb_niter_base<W,mixed_neighb<W>,
+ mln_fwd_qiter(W),neighb_fwd_niter<W> >
+ {
+ typedef
+ internal::neighb_niter_base<W,mixed_neighb<W>,
+ mln_fwd_qiter(W),neighb_fwd_niter<W> > super_;
+
+ public:
+ mixed_neighb_fwd_niter();
+
+ template <typename P>
+ mixed_neighb_fwd_niter(const mixed_neighb<W>& nbh, const P& c);
+
+ };
+
+
+
+ // mixed_neighb_bkd_niter<W,E>
+
+ template <typename W>
+ class mixed_neighb_bkd_niter
+ : public internal::neighb_niter_base<W,mixed_neighb<W>,
+ mln_bkd_qiter(W),neighb_bkd_niter<W> >
+ {
+ typedef
+ internal::neighb_niter_base<W,mixed_neighb<W>,
+ mln_bkd_qiter(W),neighb_bkd_niter<W> > super_;
+
+ public:
+ mixed_neighb_bkd_niter();
+
+ template <typename P>
+ mixed_neighb_bkd_niter(const mixed_neighb<W>& nbh, const P& c);
+
+ };
+
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ // mixed_neighb<W>
+
+ template <typename W>
+ inline
+ mixed_neighb<W>::mixed_neighb()
+ {
+ }
+
+ template <typename W>
+ inline
+ mixed_neighb<W>::mixed_neighb(const W& win)
+ : super_(win)
+ {
+ }
+
+
+ // mln::convert::from_to
+
+ namespace convert
+ {
+
+ namespace over_load
+ {
+
+ template <typename W>
+ void
+ from_to_(const mln::mixed_neighb<W>& from, W& to)
+ {
+ to = from.win();
+ }
+
+ template <typename W>
+ void
+ from_to_(const W& from, mln::mixed_neighb<W>& to)
+ {
+ to.change_window(from);
+ }
+
+ } // end of namespace mln::convert::over_load
+
+ } // end of namespace mln::convert
+
+
+
+
+ // mixed_neighb_fwd_niter<W>
+
+ template <typename W>
+ inline
+ mixed_neighb_fwd_niter<W>::mixed_neighb_fwd_niter()
+ {
+ }
+
+ template <typename W>
+ template <typename P>
+ inline
+ mixed_neighb_fwd_niter<W>::mixed_neighb_fwd_niter(const
mixed_neighb<W>& nbh,
+ const mln_target(W)& nbh_site_set,
+ const P& c)
+ : super_(nbh, c)
+ {
+ this->i_.init_(nbh.win(), nbh_site_set, c);
+ }
+
+
+
+ // mixed_neighb_bkd_niter<W>
+
+ template <typename W>
+ inline
+ mixed_neighb_bkd_niter<W>::mixed_neighb_bkd_niter()
+ {
+ }
+
+ template <typename W>
+ template <typename P>
+ inline
+ mixed_neighb_bkd_niter<W>::mixed_neighb_bkd_niter(const
mixed_neighb<W>& nbh,
+ const mln_target(W)& nbh_site_set,
+ const P& c)
+ : super_(nbh, c)
+ {
+ this->i_.init_(nbh.win(), nbh_site_set, c);
+ }
+
+
+# endif // ! MLN_INCLUDE_ONLY
+
+} // end of namespace mln
+
+
+#endif // ! MLN_CORE_MIXED_NEIGHB_HH
diff --git a/milena/mln/core/neighb.hh b/milena/mln/core/neighb.hh
index 8ce148e..db31bea 100644
--- a/milena/mln/core/neighb.hh
+++ b/milena/mln/core/neighb.hh
@@ -35,7 +35,8 @@
/// \todo See if the impl of from_to is fine. What about removing the
/// origin? etc.
-# include <mln/core/internal/neighborhood_base.hh>
+# include <mln/core/internal/neighb_base.hh>
+# include <mln/core/internal/neighb_niter_base.hh>
# include <mln/core/internal/site_relative_iterator_base.hh>
# include <mln/core/internal/neighb_niter_impl.hh>
@@ -72,9 +73,11 @@ namespace mln
/// Adapter class from window to neighborhood.
template <typename W>
- class neighb : public internal::neighborhood_base< W, neighb<W> >,
- private mlc_is_a(W, Window)::check_t
+ class neighb
+ : public internal::neighb_base<W,neighb<W> >
{
+ typedef internal::neighb_base<W,neighb<W> > super_;
+
public:
/// Forward site iterator associated type.
@@ -93,98 +96,48 @@ namespace mln
/// Constructor from a window \p win.
neighb(const W& win);
- /// Get the corresponding window.
- const W& win() const;
-
- /// Change the corresponding window.
- void change_window(const W& new_win);
-
-
- /// \internal Hook to the window.
- W& hook_win_();
-
- private:
-
- W win_;
};
-
// neighb_fwd_niter<W>
template <typename W>
class neighb_fwd_niter
- : public internal::site_relative_iterator_base< neighb<W>,
- neighb_fwd_niter<W>,
- mln_psite(neighb<W>) >,
- public internal::neighb_niter_impl<W, neighb_fwd_niter<W> >
+ : public internal::neighb_niter_base<W,neighb<W>,
+ mln_fwd_qiter(W),neighb_fwd_niter<W> >
{
- public:
+ typedef
+ internal::neighb_niter_base<W,neighb<W>,
+ mln_fwd_qiter(W),neighb_fwd_niter<W> > super_;
- /// Constructor without argument.
+ public:
neighb_fwd_niter();
template <typename P>
neighb_fwd_niter(const neighb<W>& nbh, const P& c);
- /// Test the iterator validity.
- bool is_valid_() const;
-
- /// Invalidate the iterator.
- void invalidate_();
-
- /// Start an iteration.
- void do_start_();
-
- /// Go to the next point.
- void do_next_();
-
- /// Compute the current psite.
- mln_psite(W) compute_p_() const;
-
- protected:
-
- mln_fwd_qiter(W) i_;
};
-// neighb_bkd_niter<W>
-
-template <typename W>
-class neighb_bkd_niter
- : public internal::site_relative_iterator_base< neighb<W>,
- neighb_bkd_niter<W>,
- mln_psite(neighb<W>)>,
- public internal::neighb_niter_impl<W, neighb_fwd_niter<W> >
-{
-public:
-
- /// Constructor without argument.
- neighb_bkd_niter();
-
- template <typename P>
- neighb_bkd_niter(const neighb<W>& nbh, const P& c);
-
- /// Test the iterator validity.
- bool is_valid_() const;
-
- /// Invalidate the iterator.
- void invalidate_();
-
- /// Start an iteration.
- void do_start_();
+ // neighb_bkd_niter<W,E>
- /// Go to the next point.
- void do_next_();
+ template <typename W>
+ class neighb_bkd_niter
+ : public internal::neighb_niter_base<W,neighb<W>,
+ mln_bkd_qiter(W),neighb_bkd_niter<W> >
+ {
+ typedef
+ internal::neighb_niter_base<W,neighb<W>,
+ mln_bkd_qiter(W),neighb_bkd_niter<W> > super_;
- /// Compute the current psite.
- mln_psite(W) compute_p_() const;
+ public:
+ neighb_bkd_niter();
-protected:
+ template <typename P>
+ neighb_bkd_niter(const neighb<W>& nbh, const P& c);
- mln_bkd_qiter(W) i_;
-};
+ };
@@ -201,33 +154,8 @@ protected:
template <typename W>
inline
neighb<W>::neighb(const W& win)
+ : super_(win)
{
- change_window(win);
- }
-
- template <typename W>
- inline
- const W&
- neighb<W>::win() const
- {
- return win_;
- }
-
- template <typename W>
- inline
- void
- neighb<W>::change_window(const W& new_win)
- {
- mln_precondition(new_win.is_neighbable_());
- win_ = new_win;
- }
-
- template <typename W>
- inline
- W&
- neighb<W>::hook_win_()
- {
- return win_;
}
@@ -258,6 +186,8 @@ protected:
} // end of namespace mln::convert
+
+
// neighb_fwd_niter<W>
template <typename W>
@@ -270,52 +200,11 @@ protected:
template <typename P>
inline
neighb_fwd_niter<W>::neighb_fwd_niter(const neighb<W>& nbh, const
P& c)
+ : super_(nbh, c)
{
- this->change_target(nbh);
- this->center_at(c);
- i_.center_at(c); // Always before change_target for this kind of iter.
- i_.change_target(nbh.win());
- }
-
- template <typename W>
- inline
- bool
- neighb_fwd_niter<W>::is_valid_() const
- {
- return i_.is_valid();
- }
-
- template <typename W>
- inline
- void
- neighb_fwd_niter<W>::invalidate_()
- {
- i_.invalidate();
- }
-
- template <typename W>
- inline
- void
- neighb_fwd_niter<W>::do_start_()
- {
- i_.start();
- }
-
- template <typename W>
- inline
- void
- neighb_fwd_niter<W>::do_next_()
- {
- i_.next();
+ this->i_.init_(nbh.win(), c);
}
- template <typename W>
- inline
- mln_psite(W)
- neighb_fwd_niter<W>::compute_p_() const
- {
- return i_.compute_p_();
- }
// neighb_bkd_niter<W>
@@ -330,52 +219,11 @@ protected:
template <typename P>
inline
neighb_bkd_niter<W>::neighb_bkd_niter(const neighb<W>& nbh, const
P& c)
+ : super_(nbh, c)
{
- this->change_target(nbh);
- this->center_at(c);
- i_.center_at(c); // Always before change_target for this kind of iter.
- i_.change_target(nbh.win());
+ this->i_.init_(nbh.win(), c);
}
- template <typename W>
- inline
- bool
- neighb_bkd_niter<W>::is_valid_() const
- {
- return i_.is_valid();
- }
-
- template <typename W>
- inline
- void
- neighb_bkd_niter<W>::invalidate_()
- {
- i_.invalidate();
- }
-
- template <typename W>
- inline
- void
- neighb_bkd_niter<W>::do_start_()
- {
- i_.start();
- }
-
- template <typename W>
- inline
- void
- neighb_bkd_niter<W>::do_next_()
- {
- i_.next();
- }
-
- template <typename W>
- inline
- mln_psite(W)
- neighb_bkd_niter<W>::compute_p_() const
- {
- return i_.compute_p_();
- }
# endif // ! MLN_INCLUDE_ONLY
diff --git a/milena/mln/core/window.hh b/milena/mln/core/window.hh
index af8d079..87f1940 100644
--- a/milena/mln/core/window.hh
+++ b/milena/mln/core/window.hh
@@ -1,4 +1,5 @@
-// Copyright (C) 2007, 2008, 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2007, 2008, 2009 EPITA Research and Development
+// Laboratory (LRDE)
//
// This file is part of Olena.
//
diff --git a/milena/tests/core/image/vertex_and_edge_image.cc
b/milena/tests/core/image/vertex_and_edge_image.cc
index 60a4609..05aa059 100644
--- a/milena/tests/core/image/vertex_and_edge_image.cc
+++ b/milena/tests/core/image/vertex_and_edge_image.cc
@@ -25,6 +25,7 @@
#include <vector>
+#include <mln/core/image/graph_elt_mixed_window.hh>
#include <mln/core/image/vertex_image.hh>
#include <mln/core/image/edge_image.hh>
#include <mln/fun/i2v/array.hh>
@@ -123,7 +124,7 @@ int main()
mln_piter_(v_ima_t) v(v_ima.domain());
- typedef graph_elt_window<util::graph,
+ typedef graph_elt_mixed_window<util::graph,
v_ima_t::domain_t,
e_ima_t::domain_t> edge_win_t;
edge_win_t win;
--
1.5.6.5