https://svn.lrde.epita.fr/svn/oln/trunk/milena
Index: ChangeLog
from Roland Levillain <roland(a)lrde.epita.fr>
Add neighborhoods and corresponding piters for graph-based images.
* mln/core/graph_elt_neighborhood.hh,
* mln/core/graph_neighborhood_piter.hh,
* mln/core/line_graph_elt_neighborhood.hh,
* mln/core/line_graph_neighborhood_piter.hh:
New.
* mln/core/graph_elt_window.hh,
* mln/core/graph_window_piter.hh,
* mln/core/line_graph_elt_window.hh,
* mln/core/line_graph_window_piter.hh:
More FIXME.
* mln/convert/to_window.hh (convert::nbh_to_win_trait):
New trait.
(convert::to_window(const Neighborhood<N>&)): Turn this into a
facade dispatching to...
(convert::impl::to_window(const N&))
(convert::impl::to_window(const line_graph_elt_neighborhood<P>&)):
...these (new) implementations.
* mln/convert/to_p_array.hh: Wrap long lines.
convert/to_p_array.hh | 10 +-
convert/to_window.hh | 81 +++++++++++++++++----
core/graph_elt_neighborhood.hh | 131 +++++++---------------------------
core/graph_elt_window.hh | 6 +
core/graph_neighborhood_piter.hh | 76 ++++++++++++-------
core/graph_window_piter.hh | 22 +++++
core/line_graph_elt_neighborhood.hh | 128 ++++++---------------------------
core/line_graph_elt_window.hh | 6 +
core/line_graph_neighborhood_piter.hh | 89 +++++++++++++----------
core/line_graph_window_piter.hh | 14 +++
10 files changed, 277 insertions(+), 286 deletions(-)
Index: mln/core/graph_elt_neighborhood.hh
--- mln/core/graph_elt_neighborhood.hh (revision 1723)
+++ mln/core/graph_elt_neighborhood.hh (working copy)
@@ -25,147 +25,72 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef MLN_CORE_GRAPH_ELT_WINDOW_HH
-# define MLN_CORE_GRAPH_ELT_WINDOW_HH
+#ifndef MLN_CORE_GRAPH_ELT_NEIGHBORHOOD_HH
+# define MLN_CORE_GRAPH_ELT_NEIGHBORHOOD_HH
-/*! \file mln/core/graph_elt_window.hh
+/*! \file mln/core/graph_elt_neighborhood.hh
*
- * \brief Definition of the elementary ``window'' on a graph.
+ * \brief Definition of the elementary ``neighborhood'' on a graph.
*
- * \todo Make naming coherent: we have window (without '_') but
+ * \todo Make naming coherent: we have neighborhood (without '_') but
* point_, neighb_, etc.
*/
-# include <mln/core/concept/window.hh>
+/* FIXME: Factor those classes:
+ - mln::graph_elt_window
+ - mln::graph_elt_neighborhood
+ - mln::line_graph_elt_window
+ - mln::line_graph_elt_neighborhood. */
+
+# include <mln/core/concept/neighborhood.hh>
# include <mln/core/graph_psite.hh>
-# include <mln/core/graph_window_piter.hh>
+# include <mln/core/graph_neighborhood_piter.hh>
namespace mln
{
// Fwd decls.
- template <typename P> class graph_window_fwd_piter;
- template <typename P> class graph_window_bkd_piter;
+ template <typename P> class graph_neighborhood_fwd_piter;
+ template <typename P> class graph_neighborhood_bkd_piter;
- /*! \brief Elementary window on graph class.
+ /*! \brief Elementary neighborhood on graph class.
*
* FIXME: Doc.
*/
template <typename P>
- class graph_elt_window : public Window< graph_elt_window<P> >
+ class graph_elt_neighborhood
+ : public Neighborhood< graph_elt_neighborhood<P> >
{
- typedef graph_elt_window<P> self_;
+ typedef graph_elt_neighborhood<P> self_;
public:
/// Associated types.
/// \{
- /// The type of point stored into the window.
- // FIXME: Is this right, if we consider that this window stores
+ /// The type of point stored into the neighborhood.
+ // FIXME: Is this right, if we consider that this neighborhood stores
// psites, not points?
typedef P point;
// FIXME: This is a dummy value.
typedef void dpoint;
- /*! \brief Point_Iterator type to browse the points of a generic window
- * w.r.t. the ordering of delta-points.
+ /*! \brief Point_Iterator type to browse the points of a generic
+ * neighborhood w.r.t. the ordering of delta-points.
*/
- typedef graph_window_fwd_piter<P> fwd_qiter;
+ typedef graph_neighborhood_fwd_piter<P> fwd_qiter;
- /*! \brief Point_Iterator type to browse the points of a generic window
- * w.r.t. the reverse ordering of delta-points.
+ /*! \brief Point_Iterator type to browse the points of a generic
+ * neighborhood w.r.t. the reverse ordering of delta-points.
*/
- typedef graph_window_bkd_piter<P> bkd_qiter;
+ typedef graph_neighborhood_bkd_piter<P> bkd_qiter;
/// The default qiter type.
typedef fwd_qiter qiter;
/// \}
-
- /// Construct an elementary graph window.
- graph_elt_window();
-
- /// Is the window is empty?
- bool is_empty() const;
-
- /// Is the window centered?
- bool is_centered() const;
-
- /// Is the window symmetric?
- // FIXME: We should defin this more precisely.
- bool is_symmetric() const;
-
- /// Return the maximum coordinate gap between the window center
- /// and a window point.
- /* FIXME: This method returns a dummy value (0), since the delta
- of a window on a graph
-
- 1. is not constant (graph nodes are not necessarily aligned on
- a regular grid);
-
- 2. depends on the underlying graph, too.
-
- It raises another question: should delta() be part of the
- concept ``Window''? */
- unsigned delta() const;
-
- /// Apply a central symmetry to the target window.
- self_& sym();
};
-
-# ifndef MLN_INCLUDE_ONLY
-
- template <typename P>
- inline
- graph_elt_window<P>::graph_elt_window()
- {
- }
-
- template <typename P>
- inline
- bool
- graph_elt_window<P>::is_empty() const
- {
- return false;
- }
-
- template <typename P>
- inline
- bool
- graph_elt_window<P>::is_centered() const
- {
- return false;
- }
-
- template <typename P>
- inline
- bool
- graph_elt_window<P>::is_symmetric() const
- {
- return true;
- }
-
- template <typename P>
- inline
- unsigned
- graph_elt_window<P>::delta() const
- {
- // Dummy value (see the interface of the method above).
- return 0;
- }
-
- template <typename P>
- inline
- graph_elt_window<P>&
- graph_elt_window<P>::sym()
- {
- return *this;
- }
-
-# endif // ! MLN_INCLUDE_ONLY
-
} // end of namespace mln
-#endif // ! MLN_CORE_GRAPH_ELT_WINDOW_HH
+#endif // ! MLN_CORE_GRAPH_ELT_NEIGHBORHOOD_HH
Index: mln/core/graph_neighborhood_piter.hh
--- mln/core/graph_neighborhood_piter.hh (revision 1723)
+++ mln/core/graph_neighborhood_piter.hh (working copy)
@@ -25,11 +25,25 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef MLN_CORE_GRAPH_WINDOW_PITER_HH
-# define MLN_CORE_GRAPH_WINDOW_PITER_HH
+#ifndef MLN_CORE_GRAPH_NEIGHBORHOOD_PITER_HH
+# define MLN_CORE_GRAPH_NEIGHBORHOOD_PITER_HH
-/// \file mln/core/graph_window_piter.hh
-/// \brief Definition of a point iterator on a graph window.
+/// \file mln/core/graph_neighborhood_piter.hh
+/// \brief Definition of a point iterator on a graph neighborhood.
+
+/* FIXME: Factor those classes:
+
+ - mln::graph_window_fwd_piter
+ - mln::graph_neighborhood_fwd_piter
+ - mln::line_graph_window_fwd_piter
+ - mln::line_graph_neighborhood_fwd_piter.
+
+ and later (when they get implemented):
+
+ - mln::graph_window_bkd_piter
+ - mln::graph_neighborhood_bkd_piter
+ - mln::line_graph_window_bkd_piter
+ - mln::line_graph_neighborhood_bkd_piter. */
# include <mln/core/concept/point_iterator.hh>
# include <mln/core/p_graph.hh>
@@ -48,11 +62,15 @@
template <typename P> class graph_psite;
+ /*----------------------------------.
+ | graph_neighborhood_fwd_piter<P>. |
+ `----------------------------------*/
+
template <typename P>
- class graph_window_fwd_piter :
- public Point_Iterator< graph_window_fwd_piter<P> > // or
Iterator<...>?
+ class graph_neighborhood_fwd_piter :
+ public Point_Iterator< graph_neighborhood_fwd_piter<P> > // or
Iterator<...>?
{
- typedef graph_window_fwd_piter<P> self_;
+ typedef graph_neighborhood_fwd_piter<P> self_;
typedef Point_Iterator< self_ > super_;
public:
@@ -68,8 +86,8 @@
typedef mln_coord(P) coord;
public:
- template <typename W, typename Pref>
- graph_window_fwd_piter(const W& win, const Point_Site<Pref>& p_ref);
+ template <typename N, typename Pref>
+ graph_neighborhood_fwd_piter(const N& nbh, const Point_Site<Pref>&
p_ref);
bool is_valid() const;
void invalidate();
@@ -92,7 +110,7 @@
coord operator[](unsigned i) const;
private:
- /// The ``central'' psite of the window.
+ /// The ``central'' psite of the neighborhood.
const psite& p_ref_;
/// An internal iterator on the set of nodes of the underlying graph.
util::node_id id_;
@@ -102,16 +120,18 @@
point p_;
};
- // FIXME: Implement graph_window_bkd_piter.
+ /*----------------------------------.
+ | graph_neighborhood_bkd_piter<P>. |
+ `----------------------------------*/
# ifndef MLN_INCLUDE_ONLY
- // FIXME: Currently, argument win is ignored.
+ // FIXME: Currently, argument nbh is ignored.
template <typename P>
- template <typename W, typename Pref>
+ template <typename N, typename Pref>
inline
- graph_window_fwd_piter<P>::graph_window_fwd_piter(const W& /* win */,
+ graph_neighborhood_fwd_piter<P>::graph_neighborhood_fwd_piter(const N& /* nbh
*/,
const Point_Site<Pref>& p_ref)
: p_ref_(exact(p_ref).to_psite()),
// Initialize psite_ to a dummy value.
@@ -125,7 +145,7 @@
template <typename P>
inline
bool
- graph_window_fwd_piter<P>::is_valid() const
+ graph_neighborhood_fwd_piter<P>::is_valid() const
{
// FIXME: We depend too much on the implementation of util::graph
// here. The util::graph should provide the service to abstract
@@ -136,7 +156,7 @@
template <typename P>
inline
void
- graph_window_fwd_piter<P>::invalidate()
+ graph_neighborhood_fwd_piter<P>::invalidate()
{
id_ = p_ref_.pg().gr_.nnodes();
}
@@ -144,7 +164,7 @@
template <typename P>
inline
void
- graph_window_fwd_piter<P>::start()
+ graph_neighborhood_fwd_piter<P>::start()
{
id_ = 0;
if (!adjacent_or_equal_to_p_ref_())
@@ -159,15 +179,15 @@
template <typename P>
inline
void
- graph_window_fwd_piter<P>::next_()
+ graph_neighborhood_fwd_piter<P>::next_()
{
/* FIXME: This is inefficient. The graph structure should be able
to produce the set of adjacent nodes fast. Boost Graphs
probably provides adequates structures to fetch these
neighbors in constant time. */
/* FIXME: Moreover, the behavior of next shall depend on the
- window, which is not the case now! (Currently, next_() behaves
- as win was always an elementary window.) */
+ neighborhood, which is not the case now! (Currently, next_() behaves
+ as nbh was always an elementary neighborhood.) */
do
++id_;
while (is_valid() && !adjacent_or_equal_to_p_ref_());
@@ -178,7 +198,7 @@
template <typename P>
inline
bool
- graph_window_fwd_piter<P>::adjacent_or_equal_to_p_ref_() const
+ graph_neighborhood_fwd_piter<P>::adjacent_or_equal_to_p_ref_() const
{
// FIXME: Likewise, this is inefficient.
@@ -208,7 +228,7 @@
template <typename P>
inline
void
- graph_window_fwd_piter<P>::update_()
+ graph_neighborhood_fwd_piter<P>::update_()
{
// Update psite_.
psite_ = graph_psite<P>(p_ref_.pg(), id_);
@@ -219,7 +239,7 @@
template <typename P>
inline
const P&
- graph_window_fwd_piter<P>::to_point() const
+ graph_neighborhood_fwd_piter<P>::to_point() const
{
return p_;
}
@@ -227,14 +247,14 @@
template <typename P>
inline
const graph_psite<P>&
- graph_window_fwd_piter<P>::to_psite() const
+ graph_neighborhood_fwd_piter<P>::to_psite() const
{
return psite_;
}
template <typename P>
inline
- graph_window_fwd_piter<P>::operator P() const
+ graph_neighborhood_fwd_piter<P>::operator P() const
{
mln_precondition(is_valid());
return p_;
@@ -242,7 +262,7 @@
template <typename P>
inline
- graph_window_fwd_piter<P>::operator graph_psite<P>() const
+ graph_neighborhood_fwd_piter<P>::operator graph_psite<P>() const
{
mln_precondition(is_valid());
return psite_;
@@ -251,7 +271,7 @@
template <typename P>
inline
mln_coord(P)
- graph_window_fwd_piter<P>::operator[](unsigned i) const
+ graph_neighborhood_fwd_piter<P>::operator[](unsigned i) const
{
assert(i < dim);
return p_[i];
@@ -261,4 +281,4 @@
} // end of namespace mln
-#endif // ! MLN_CORE_GRAPH_WINDOW_PITER_HH
+#endif // ! MLN_CORE_GRAPH_NEIGHBORHOOD_PITER_HH
Index: mln/core/line_graph_elt_neighborhood.hh
--- mln/core/line_graph_elt_neighborhood.hh (revision 1719)
+++ mln/core/line_graph_elt_neighborhood.hh (working copy)
@@ -25,10 +25,10 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef MLN_CORE_LINE_GRAPH_ELT_WINDOW_HH
-# define MLN_CORE_LINE_GRAPH_ELT_WINDOW_HH
+#ifndef MLN_CORE_LINE_GRAPH_ELT_NEIGHBORHOOD_HH
+# define MLN_CORE_LINE_GRAPH_ELT_NEIGHBORHOOD_HH
-/*! \file mln/core/line_graph_elt_window.hh
+/*! \file mln/core/line_graph_elt_neighborhood.hh
*
* \brief Definition of the elementary ``window'' on a line graph.
*
@@ -36,136 +36,60 @@
* point_, neighb_, etc.
*/
-# include <mln/core/concept/window.hh>
+# include <mln/core/concept/neighborhood.hh>
# include <mln/core/line_graph_psite.hh>
-# include <mln/core/line_graph_window_piter.hh>
+# include <mln/core/line_graph_neighborhood_piter.hh>
+/* FIXME: Factor those classes:
+ - mln::graph_elt_window
+ - mln::graph_elt_neighborhood
+ - mln::line_graph_elt_window
+ - mln::line_graph_elt_neighborhood. */
namespace mln
{
// Fwd decls.
- template <typename P> class line_graph_window_fwd_piter;
- template <typename P> class line_graph_window_bkd_piter;
+ template <typename P> class line_graph_neighborhood_fwd_piter;
+ template <typename P> class line_graph_neighborhood_bkd_piter;
- /*! \brief Elementary window on line graph class.
+ /*! \brief Elementary neighborhood on line graph class.
*
* FIXME: Doc.
*/
template <typename P>
- class line_graph_elt_window : public Window< line_graph_elt_window<P> >
+ class line_graph_elt_neighborhood
+ : public Neighborhood< line_graph_elt_neighborhood<P> >
{
- typedef line_graph_elt_window<P> self_;
+ typedef line_graph_elt_neighborhood<P> self_;
public:
/// Associated types.
/// \{
- /// The type of point stored into the window.
- // FIXME: Is this right, if we consider that this window stores
+ /// The type of point stored into the neighborhood.
+ // FIXME: Is this right, if we consider that this neighborhood stores
// psites, not points?
typedef P point;
// FIXME: This is a dummy value.
typedef void dpoint;
- /*! \brief Point_Iterator type to browse the points of a generic window
- * w.r.t. the ordering of delta-points.
+ /*! \brief Point_Iterator type to browse the points of a generic
+ * neighborhood w.r.t. the ordering of delta-points.
*/
- typedef line_graph_window_fwd_piter<P> fwd_qiter;
+ typedef line_graph_neighborhood_fwd_piter<P> fwd_niter;
- /*! \brief Point_Iterator type to browse the points of a generic window
- * w.r.t. the reverse ordering of delta-points.
+ /*! \brief Point_Iterator type to browse the points of a generic
+ * neighborhood w.r.t. the reverse ordering of delta-points.
*/
- typedef line_graph_window_bkd_piter<P> bkd_qiter;
+ typedef line_graph_neighborhood_bkd_piter<P> bkd_niter;
/// The default qiter type.
- typedef fwd_qiter qiter;
+ typedef fwd_niter niter;
/// \}
-
- /// Construct an elementary line_graph window.
- line_graph_elt_window();
-
- /// Is the window is empty?
- bool is_empty() const;
-
- /// Is the window centered?
- bool is_centered() const;
-
- /// Is the window symmetric?
- // FIXME: We should defin this more precisely.
- bool is_symmetric() const;
-
- /// Return the maximum coordinate gap between the window center
- /// and a window point.
- /* FIXME: This method returns a dummy value (0), since the delta
- of a window on a line_graph
-
- 1. is not constant (line graph edges are not necessarily
- aligned on a regular grid);
-
- 2. depends on the underlying line_graph, too.
-
- It raises another question: should delta() be part of the
- concept ``Window''? */
- unsigned delta() const;
-
- /// Apply a central symmetry to the target window.
- self_& sym();
};
-
-# ifndef MLN_INCLUDE_ONLY
-
- template <typename P>
- inline
- line_graph_elt_window<P>::line_graph_elt_window()
- {
- }
-
- template <typename P>
- inline
- bool
- line_graph_elt_window<P>::is_empty() const
- {
- return false;
- }
-
- template <typename P>
- inline
- bool
- line_graph_elt_window<P>::is_centered() const
- {
- return false;
- }
-
- template <typename P>
- inline
- bool
- line_graph_elt_window<P>::is_symmetric() const
- {
- return true;
- }
-
- template <typename P>
- inline
- unsigned
- line_graph_elt_window<P>::delta() const
- {
- // Dummy value (see the interface of the method above).
- return 0;
- }
-
- template <typename P>
- inline
- line_graph_elt_window<P>&
- line_graph_elt_window<P>::sym()
- {
- return *this;
- }
-
-# endif // ! MLN_INCLUDE_ONLY
-
} // end of namespace mln
-#endif // ! MLN_CORE_LINE_GRAPH_ELT_WINDOW_HH
+#endif // ! MLN_CORE_LINE_GRAPH_ELT_NEIGHBORHOOD_HH
Index: mln/core/line_graph_neighborhood_piter.hh
--- mln/core/line_graph_neighborhood_piter.hh (revision 1719)
+++ mln/core/line_graph_neighborhood_piter.hh (working copy)
@@ -25,11 +25,25 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef MLN_CORE_LINE_GRAPH_WINDOW_PITER_HH
-# define MLN_CORE_LINE_GRAPH_WINDOW_PITER_HH
+#ifndef MLN_CORE_LINE_GRAPH_NEIGHBORHOOD_PITER_HH
+# define MLN_CORE_LINE_GRAPH_NEIGHBORHOOD_PITER_HH
-/// \file mln/core/line_graph_window_piter.hh
-/// \brief Definition of a point iterator on a line_graph window.
+/// \file mln/core/line_graph_neighborhood_piter.hh
+/// \brief Definition of a point iterator on a line_graph neighborhood.
+
+/* FIXME: Factor those classes:
+
+ - mln::graph_window_fwd_piter
+ - mln::graph_neighborhood_fwd_piter
+ - mln::line_graph_window_fwd_piter
+ - mln::line_graph_neighborhood_fwd_piter.
+
+ and later (when they get implemented):
+
+ - mln::graph_window_bkd_piter
+ - mln::graph_neighborhood_bkd_piter
+ - mln::line_graph_window_bkd_piter
+ - mln::line_graph_neighborhood_bkd_piter. */
# include <mln/core/concept/point_iterator.hh>
# include <mln/core/p_line_graph.hh>
@@ -49,15 +63,15 @@
template <typename P> class line_graph_psite;
- /*---------------------------------.
- | line_graph_window_fwd_piter<P>. |
- `---------------------------------*/
+ /*---------------------------------------.
+ | line_graph_neighborhood_fwd_piter<P>. |
+ `---------------------------------------*/
template <typename P>
- class line_graph_window_fwd_piter :
- public Point_Iterator< line_graph_window_fwd_piter<P> > // or
Iterator<...>?
+ class line_graph_neighborhood_fwd_piter :
+ public Point_Iterator< line_graph_neighborhood_fwd_piter<P> > // or
Iterator<...>?
{
- typedef line_graph_window_fwd_piter<P> self_;
+ typedef line_graph_neighborhood_fwd_piter<P> self_;
typedef Point_Iterator< self_ > super_;
public:
@@ -73,8 +87,9 @@
typedef mln_coord(point) coord;
public:
- template <typename W, typename Pref>
- line_graph_window_fwd_piter(const W& win, const Point_Site<Pref>&
p_ref);
+ template <typename N, typename Pref>
+ line_graph_neighborhood_fwd_piter(const N& nbh,
+ const Point_Site<Pref>& p_ref);
bool is_valid() const;
void invalidate();
@@ -95,7 +110,7 @@
coord operator[](unsigned i) const;
private:
- /// The ``central'' psite of the window.
+ /// The ``central'' psite of the neighborhood.
const psite& p_ref_;
/// An internal iterator on the set of edges of the underlying graph.
util::edge_id id_;
@@ -112,23 +127,24 @@
template <typename P>
inline
std::ostream&
- operator<<(std::ostream& ostr, const
line_graph_window_fwd_piter<P>& p);
+ operator<<(std::ostream& ostr,
+ const line_graph_neighborhood_fwd_piter<P>& p);
- /*---------------------------------.
- | line_graph_window_bkd_piter<P>. |
- `---------------------------------*/
+ /*---------------------------------------.
+ | line_graph_neighborhood_bkd_piter<P>. |
+ `---------------------------------------*/
- // FIXME: Implement line_graph_window_bkd_piter.
+ // FIXME: Implement line_graph_neighborhood_bkd_piter.
# ifndef MLN_INCLUDE_ONLY
- // FIXME: Currently, argument win is ignored.
+ // FIXME: Currently, argument nbh is ignored.
template <typename P>
- template <typename W, typename Pref>
+ template <typename N, typename Pref>
inline
- line_graph_window_fwd_piter<P>::line_graph_window_fwd_piter(const W& /* win
*/,
+ line_graph_neighborhood_fwd_piter<P>::line_graph_neighborhood_fwd_piter(const
N& /* nbh */,
const Point_Site<Pref>& p_ref)
: p_ref_(exact(p_ref).to_psite()),
// Initialize psite_ to a dummy value.
@@ -142,7 +158,7 @@
template <typename P>
inline
bool
- line_graph_window_fwd_piter<P>::is_valid() const
+ line_graph_neighborhood_fwd_piter<P>::is_valid() const
{
// FIXME: We depend too much on the implementation of util::graph
// here. The util::graph should provide the service to abstract
@@ -153,7 +169,7 @@
template <typename P>
inline
void
- line_graph_window_fwd_piter<P>::invalidate()
+ line_graph_neighborhood_fwd_piter<P>::invalidate()
{
id_ = p_ref_.plg().gr_.nedges();
}
@@ -161,7 +177,7 @@
template <typename P>
inline
void
- line_graph_window_fwd_piter<P>::start()
+ line_graph_neighborhood_fwd_piter<P>::start()
{
id_ = 0;
if (!adjacent_or_equal_to_p_ref_())
@@ -176,15 +192,15 @@
template <typename P>
inline
void
- line_graph_window_fwd_piter<P>::next_()
+ line_graph_neighborhood_fwd_piter<P>::next_()
{
/* FIXME: This is inefficient. The graph structure should be able
to produce the set of adjacent edges fast. Boost Graphs
probably provides adequates structures to fetch these
neighbors in constant time. */
/* FIXME: Moreover, the behavior of next shall depend on the
- window, which is not the case now! (Currently, next_() behaves
- as win was always an elementary window.) */
+ neighborhood, which is not the case now! (Currently, next_()
+ behaves as nbh was always an elementary neighborhood.) */
do
++id_;
while (is_valid() && !adjacent_or_equal_to_p_ref_());
@@ -195,7 +211,7 @@
template <typename P>
inline
bool
- line_graph_window_fwd_piter<P>::adjacent_or_equal_to_p_ref_() const
+ line_graph_neighborhood_fwd_piter<P>::adjacent_or_equal_to_p_ref_() const
{
// Check wether the iterator points to P_REF_.
if (id_ == p_ref_.id())
@@ -227,7 +243,7 @@
template <typename P>
inline
void
- line_graph_window_fwd_piter<P>::update_()
+ line_graph_neighborhood_fwd_piter<P>::update_()
{
// Update psite_.
psite_ = line_graph_psite<P>(p_ref_.plg(), id_);
@@ -241,7 +257,7 @@
template <typename P>
inline
const point_pair<P>&
- line_graph_window_fwd_piter<P>::to_point() const
+ line_graph_neighborhood_fwd_piter<P>::to_point() const
{
return p_;
}
@@ -249,14 +265,14 @@
template <typename P>
inline
const line_graph_psite<P>&
- line_graph_window_fwd_piter<P>::to_psite() const
+ line_graph_neighborhood_fwd_piter<P>::to_psite() const
{
return psite_;
}
template <typename P>
inline
- line_graph_window_fwd_piter<P>::operator point_pair<P>() const
+ line_graph_neighborhood_fwd_piter<P>::operator point_pair<P>() const
{
mln_precondition(is_valid());
return p_;
@@ -264,7 +280,7 @@
template <typename P>
inline
- line_graph_window_fwd_piter<P>::operator line_graph_psite<P> () const
+ line_graph_neighborhood_fwd_piter<P>::operator line_graph_psite<P> ()
const
{
mln_precondition(is_valid());
return psite_;
@@ -273,7 +289,7 @@
template <typename P>
inline
mln_coord(point_pair<P>)
- line_graph_window_fwd_piter<P>::operator[](unsigned i) const
+ line_graph_neighborhood_fwd_piter<P>::operator[](unsigned i) const
{
assert(i < dim);
return p_[i];
@@ -282,7 +298,8 @@
template <typename P>
inline
std::ostream&
- operator<<(std::ostream& ostr, const
line_graph_window_fwd_piter<P>& p)
+ operator<<(std::ostream& ostr,
+ const line_graph_neighborhood_fwd_piter<P>& p)
{
return ostr << p.to_point();
}
@@ -291,4 +308,4 @@
} // end of namespace mln
-#endif // ! MLN_CORE_LINE_GRAPH_WINDOW_PITER_HH
+#endif // ! MLN_CORE_LINE_GRAPH_NEIGHBORHOOD_PITER_HH
Index: mln/core/graph_elt_window.hh
--- mln/core/graph_elt_window.hh (revision 1724)
+++ mln/core/graph_elt_window.hh (working copy)
@@ -36,6 +36,12 @@
* point_, neighb_, etc.
*/
+/* FIXME: Factor those classes:
+ - mln::graph_elt_window
+ - mln::graph_elt_neighborhood
+ - mln::line_graph_elt_window
+ - mln::line_graph_elt_neighborhood. */
+
# include <mln/core/concept/window.hh>
# include <mln/core/graph_psite.hh>
# include <mln/core/graph_window_piter.hh>
Index: mln/core/graph_window_piter.hh
--- mln/core/graph_window_piter.hh (revision 1724)
+++ mln/core/graph_window_piter.hh (working copy)
@@ -31,6 +31,20 @@
/// \file mln/core/graph_window_piter.hh
/// \brief Definition of a point iterator on a graph window.
+/* FIXME: Factor those classes:
+
+ - mln::graph_window_fwd_piter
+ - mln::graph_neighborhood_fwd_piter
+ - mln::line_graph_window_fwd_piter
+ - mln::line_graph_neighborhood_fwd_piter.
+
+ and later (when they get implemented):
+
+ - mln::graph_window_bkd_piter
+ - mln::graph_neighborhood_bkd_piter
+ - mln::line_graph_window_bkd_piter
+ - mln::line_graph_neighborhood_bkd_piter. */
+
# include <mln/core/concept/point_iterator.hh>
# include <mln/core/p_graph.hh>
# include <mln/core/graph_psite.hh>
@@ -48,6 +62,10 @@
template <typename P> class graph_psite;
+ /*----------------------------.
+ | graph_window_fwd_piter<P>. |
+ `----------------------------*/
+
template <typename P>
class graph_window_fwd_piter :
public Point_Iterator< graph_window_fwd_piter<P> > // or
Iterator<...>?
@@ -102,7 +120,9 @@
point p_;
};
- // FIXME: Implement graph_window_bkd_piter.
+ /*----------------------------.
+ | graph_window_bkd_piter<P>. |
+ `----------------------------*/
# ifndef MLN_INCLUDE_ONLY
Index: mln/core/line_graph_elt_window.hh
--- mln/core/line_graph_elt_window.hh (revision 1724)
+++ mln/core/line_graph_elt_window.hh (working copy)
@@ -36,6 +36,12 @@
* point_, neighb_, etc.
*/
+/* FIXME: Factor those classes:
+ - mln::graph_elt_window
+ - mln::graph_elt_neighborhood
+ - mln::line_graph_elt_window
+ - mln::line_graph_elt_neighborhood. */
+
# include <mln/core/concept/window.hh>
# include <mln/core/line_graph_psite.hh>
# include <mln/core/line_graph_window_piter.hh>
Index: mln/core/line_graph_window_piter.hh
--- mln/core/line_graph_window_piter.hh (revision 1724)
+++ mln/core/line_graph_window_piter.hh (working copy)
@@ -31,6 +31,20 @@
/// \file mln/core/line_graph_window_piter.hh
/// \brief Definition of a point iterator on a line_graph window.
+/* FIXME: Factor those classes:
+
+ - mln::graph_window_fwd_piter
+ - mln::graph_neighborhood_fwd_piter
+ - mln::line_graph_window_fwd_piter
+ - mln::line_graph_neighborhood_fwd_piter.
+
+ and later (when they get implemented):
+
+ - mln::graph_window_bkd_piter
+ - mln::graph_neighborhood_bkd_piter
+ - mln::line_graph_window_bkd_piter
+ - mln::line_graph_neighborhood_bkd_piter. */
+
# include <mln/core/concept/point_iterator.hh>
# include <mln/core/p_line_graph.hh>
# include <mln/core/line_graph_psite.hh>
Index: mln/convert/to_window.hh
--- mln/convert/to_window.hh (revision 1724)
+++ mln/convert/to_window.hh (working copy)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory (LRDE)
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -42,16 +42,34 @@
# include <mln/pw/cst.hh>
# include <mln/metal/is_a.hh>
+# include <mln/core/line_graph_elt_neighborhood.hh>
+# include <mln/core/line_graph_elt_window.hh>
+
namespace mln
{
namespace convert
{
+ // Return type trait of neighborhood-to-window conversions.
+
+ /* FIXME: This trait should probably be moved elsewhere. And/or
+ it could encapsulate the conversion function, too. */
+
+ // Default case.
+ template <typename N>
+ struct nbh_to_win_trait
+ { typedef window<mln_dpoint(N)> ret; };
+
+ // Case of line_graph_elt_neighborhood<P>.
+ template <typename P>
+ struct nbh_to_win_trait< line_graph_elt_neighborhood<P> >
+ { typedef line_graph_elt_window<P> ret; };
+
/// Convert a neighborhood \p nbh into a window.
template <typename N>
- window<mln_dpoint(N)> to_window(const Neighborhood<N>& nbh);
+ typename nbh_to_win_trait<N>::ret to_window(const Neighborhood<N>&
nbh);
/// Convert a binary image \p ima into a window.
template <typename I>
@@ -68,18 +86,16 @@
# ifndef MLN_INCLUDE_ONLY
- /* FIXME: According to milena/core/concepts/README, windows are
- not necessarily based on a set of dpoints. So the current
- algorithm won't work on non dpoint-set-based windows. In the
- general case (of windows not being a set of dpoints), the
- window resulting from this conversion (as well as the iterators
- based on such windows!) should depend on the initial
- neighborhood (i.e., delegate the actual iteration to the
- aggregated neighborhood). When this is fixed, document this in
- depth in milena/core/concepts/README. */
+ /*-------------------------------------.
+ | Neighborhood-to-window conversions. |
+ `-------------------------------------*/
+
+ namespace impl
+ {
+
template <typename N>
inline
- window<mln_dpoint(N)> to_window(const Neighborhood<N>& nbh_)
+ window<mln_dpoint(N)> to_window(const N& nbh_)
{
const N& nbh = exact(nbh_);
typedef mln_dpoint(N) D;
@@ -91,7 +107,38 @@
return win;
}
- // FIXME: Same remark as for to_window(const Neighborhood<N>&)
+ template <typename P>
+ inline
+ line_graph_elt_window<P>
+ to_window(const line_graph_elt_neighborhood<P>& /* nbh_ */ )
+ {
+ return line_graph_elt_window<P>();
+ }
+
+ } // end of namepace mln::convert::impl
+
+
+ // Facade.
+ template <typename N>
+ inline
+ typename nbh_to_win_trait<N>::ret to_window(const Neighborhood<N>&
nbh)
+ {
+ return impl::to_window(exact(nbh));
+ }
+
+ /*------------------------------.
+ | Image-to-window conversions. |
+ `------------------------------*/
+
+ /* FIXME: According to milena/core/concepts/README, windows are
+ not necessarily based on a set of dpoints. So the current
+ algorithm won't work on non dpoint-set-based windows. In the
+ general case (of windows not being a set of dpoints), the
+ window resulting from this conversion (as well as the iterators
+ based on such windows!) should depend on the initial
+ neighborhood (i.e., delegate the actual iteration to the
+ aggregated neighborhood). When this is fixed, document this in
+ depth in milena/core/concepts/README. */
template <typename I>
inline
window<mln_dpoint(I)> to_window(const Image<I>& ima_)
@@ -109,6 +156,10 @@
return win;
}
+ /*----------------------------------.
+ | Point set-to-window conversions. |
+ `----------------------------------*/
+
template <typename S>
inline
window<mln_dpoint(S)> to_window(const Point_Set<S>& pset)
@@ -116,6 +167,10 @@
return to_window(pw::cst(true) | pset);
}
+ /*---------------------------------.
+ | std::set-to-window conversions. |
+ `---------------------------------*/
+
template <typename D>
inline
window<D> to_window(const std::set<D>& s)
Index: mln/convert/to_p_array.hh
--- mln/convert/to_p_array.hh (revision 1724)
+++ mln/convert/to_p_array.hh (working copy)
@@ -48,9 +48,12 @@
p_array<mln_point(S)> to_p_array(const Point_Set<S>& pset);
- /// Convert a window \p win centered at point \p p into a p_array (point set
vector).
+ /// Convert a window \p win centered at point \p p into a p_array
+ /// (point set vector).
template <typename W>
- p_array<mln_point(W)> to_p_array(const Window<W>& win, const
mln_point(W)& p);
+ p_array<mln_point(W)> to_p_array(const Window<W>& win,
+ const mln_point(W)& p);
+
# ifndef MLN_INCLUDE_ONLY
@@ -70,7 +73,8 @@
template <typename W>
inline
- p_array<mln_point(W)> to_p_array(const Window<W>& win, const
mln_point(W)& p)
+ p_array<mln_point(W)> to_p_array(const Window<W>& win,
+ const mln_point(W)& p)
{
p_array<mln_point(W)> v;
v.reserve(exact(win).ndpoints());