Olena-patches
Threads by month
- ----- 2025 -----
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2007 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2006 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2005 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2004 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- 9625 discussions
18 Oct '08
* mln/core/image/complex_windows.hh
(mln::complex_lower_dim_connected_n_face_window_p)
(mln::complex_higher_dim_connected_n_face_window_p):
New windows.
(trait::window_< complex_lower_dim_connected_n_face_window_p<D, G> >)
(trait::window_< complex_higher_dim_connected_n_face_window_p<D, G> >):
New traits.
Exercise these new windows...
* tests/morpho/complex_image_morpho.cc: ...here.
---
milena/ChangeLog | 14 +++++++
milena/mln/core/image/complex_windows.hh | 54 +++++++++++++++++++++++++++
milena/tests/morpho/complex_image_morpho.cc | 5 ++
3 files changed, 73 insertions(+), 0 deletions(-)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index 185b935..37db01d 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,5 +1,19 @@
2008-10-18 Roland Levillain <roland(a)lrde.epita.fr>
+ Add windows based on lower/higher-dimension connected n-faces.
+
+ * mln/core/image/complex_windows.hh
+ (mln::complex_lower_dim_connected_n_face_window_p)
+ (mln::complex_higher_dim_connected_n_face_window_p):
+ New windows.
+ (trait::window_< complex_lower_dim_connected_n_face_window_p<D, G> >)
+ (trait::window_< complex_higher_dim_connected_n_face_window_p<D, G> >):
+ New traits.
+ Exercise these new windows...
+ * tests/morpho/complex_image_morpho.cc: ...here.
+
+2008-10-18 Roland Levillain <roland(a)lrde.epita.fr>
+
Add neighborhoods based on lower/higher-dimension connected n-faces.
* mln/core/image/complex_neighborhoods.hh
diff --git a/milena/mln/core/image/complex_windows.hh b/milena/mln/core/image/complex_windows.hh
index 662b528..6c074e7 100644
--- a/milena/mln/core/image/complex_windows.hh
+++ b/milena/mln/core/image/complex_windows.hh
@@ -75,6 +75,38 @@ namespace mln
{
};
+ /// \brief Window centered on an n-face of complex returning the
+ /// n-faces sharing an (n-1)-face with the center n-face, as well as
+ /// this center n-face.
+ template <unsigned D, typename G>
+ struct complex_lower_dim_connected_n_face_window_p
+ : internal::complex_window_p_base<
+ D, G,
+ topo::adj_lower_dim_connected_n_face_fwd_iter<D>,
+ topo::adj_lower_dim_connected_n_face_bkd_iter<D>,
+ complex_lower_dim_connected_n_face_window_p<D, G>
+ >
+ {
+ };
+
+ /// \brief Window centered on an n-face of complex returning the
+ /// n-faces sharing an (n+1)-face with the center n-face, as well as
+ /// this center n-face.
+ template <unsigned D, typename G>
+ struct complex_higher_dim_connected_n_face_window_p
+ : internal::complex_window_p_base<
+ D, G,
+ topo::adj_higher_dim_connected_n_face_fwd_iter<D>,
+ topo::adj_higher_dim_connected_n_face_bkd_iter<D>,
+ complex_higher_dim_connected_n_face_window_p<D, G>
+ >
+ {
+ };
+
+
+ // -------- //
+ // Traits. //
+ // -------- //
namespace trait
{
@@ -112,6 +144,28 @@ namespace mln
{
};
+ template <unsigned D, typename G>
+ struct window_< mln::complex_lower_dim_connected_n_face_window_p<D, G> >
+ : window_< mln::internal::complex_window_p_base<
+ D, G,
+ mln::topo::adj_lower_dim_connected_n_face_fwd_iter<D>,
+ mln::topo::adj_lower_dim_connected_n_face_bkd_iter<D>,
+ mln::complex_lower_dim_connected_n_face_window_p<D, G> >
+ >
+ {
+ };
+
+ template <unsigned D, typename G>
+ struct window_< mln::complex_higher_dim_connected_n_face_window_p<D, G> >
+ : window_< mln::internal::complex_window_p_base<
+ D, G,
+ mln::topo::adj_higher_dim_connected_n_face_fwd_iter<D>,
+ mln::topo::adj_higher_dim_connected_n_face_bkd_iter<D>,
+ mln::complex_higher_dim_connected_n_face_window_p<D, G> >
+ >
+ {
+ };
+
} // end of namespace mln::trait
} // end of namespace mln
diff --git a/milena/tests/morpho/complex_image_morpho.cc b/milena/tests/morpho/complex_image_morpho.cc
index bcf74bd..80b80f5 100644
--- a/milena/tests/morpho/complex_image_morpho.cc
+++ b/milena/tests/morpho/complex_image_morpho.cc
@@ -162,6 +162,11 @@ int main()
test_morpho(ima, complex_lower_higher_window_p<D, G>(),
"lower- and higer-dimension faces");
+ test_morpho(ima, complex_lower_dim_connected_n_face_window_p<D, G>(),
+ "lower-dimension connected n-faces");
+ test_morpho(ima, complex_higher_dim_connected_n_face_window_p<D, G>(),
+ "higher-dimension connected n-faces");
+
/* FIXME: Exercise elementary erosion/dilation (with neighborhoods)
when available. */
}
--
1.6.0.1
1
0
2605: Add neighborhoods based on lower/higher-dimension connected n-faces.
by Roland Levillain 18 Oct '08
by Roland Levillain 18 Oct '08
18 Oct '08
* mln/core/image/complex_neighborhoods.hh
(mln::complex_lower_dim_connected_n_face_neighborhood<D, G>):
(mln::complex_higher_dim_connected_n_face_neighborhood<D, G>):
New neighborhoods.
Exercise them...
* tests/core/image/complex_image.cc: ...here.
---
milena/ChangeLog | 11 +++++++++
milena/mln/core/image/complex_neighborhoods.hh | 28 ++++++++++++++++++++++++
milena/tests/core/image/complex_image.cc | 6 +++++
3 files changed, 45 insertions(+), 0 deletions(-)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index 2959330..185b935 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,5 +1,16 @@
2008-10-18 Roland Levillain <roland(a)lrde.epita.fr>
+ Add neighborhoods based on lower/higher-dimension connected n-faces.
+
+ * mln/core/image/complex_neighborhoods.hh
+ (mln::complex_lower_dim_connected_n_face_neighborhood<D, G>):
+ (mln::complex_higher_dim_connected_n_face_neighborhood<D, G>):
+ New neighborhoods.
+ Exercise them...
+ * tests/core/image/complex_image.cc: ...here.
+
+2008-10-18 Roland Levillain <roland(a)lrde.epita.fr>
+
Have tests/morpho/complex_image_morpho.cc be more verbose/specific.
* tests/morpho/complex_image_morpho.cc (test_morpho): Take an
diff --git a/milena/mln/core/image/complex_neighborhoods.hh b/milena/mln/core/image/complex_neighborhoods.hh
index 174f263..3dce74f 100644
--- a/milena/mln/core/image/complex_neighborhoods.hh
+++ b/milena/mln/core/image/complex_neighborhoods.hh
@@ -36,6 +36,8 @@
# include <mln/topo/adj_lower_face_iter.hh>
# include <mln/topo/adj_higher_face_iter.hh>
# include <mln/topo/adj_lower_higher_face_iter.hh>
+# include <mln/topo/adj_lower_dim_connected_n_face_iter.hh>
+# include <mln/topo/adj_higher_dim_connected_n_face_iter.hh>
namespace mln
@@ -76,6 +78,32 @@ namespace mln
{
};
+ /// \brief Neighborhood centered on an n-face of complex returning
+ /// the n-faces sharing an (n-1)-face with the center n-face.
+ template <unsigned D, typename G>
+ struct complex_lower_dim_connected_n_face_neighborhood
+ : internal::complex_neighborhood_base<
+ D, G,
+ topo::adj_lower_dim_connected_n_face_fwd_iter<D>,
+ topo::adj_lower_dim_connected_n_face_bkd_iter<D>,
+ complex_lower_dim_connected_n_face_neighborhood<D, G>
+ >
+ {
+ };
+
+ /// \brief Neighborhood centered on an n-face of complex returning
+ /// the n-faces sharing an (n+1)-face with the center n-face.
+ template <unsigned D, typename G>
+ struct complex_higher_dim_connected_n_face_neighborhood
+ : internal::complex_neighborhood_base<
+ D, G,
+ topo::adj_higher_dim_connected_n_face_fwd_iter<D>,
+ topo::adj_higher_dim_connected_n_face_bkd_iter<D>,
+ complex_higher_dim_connected_n_face_neighborhood<D, G>
+ >
+ {
+ };
+
} // end of namespace mln
#endif // ! MLN_CORE_IMAGE_COMPLEX_NEIGHBORHOODS_HH
diff --git a/milena/tests/core/image/complex_image.cc b/milena/tests/core/image/complex_image.cc
index 36028fc..27dfeb0 100644
--- a/milena/tests/core/image/complex_image.cc
+++ b/milena/tests/core/image/complex_image.cc
@@ -231,6 +231,12 @@ int main()
test_neighborhood(ima, complex_lower_higher_neighborhood<D, G>(),
"Lower- and higer-dimension faces");
+ test_neighborhood(ima,
+ complex_lower_dim_connected_n_face_neighborhood<D, G>(),
+ "Lower-dimension connected n-faces");
+ test_neighborhood(ima,
+ complex_higher_dim_connected_n_face_neighborhood<D, G>(),
+ "Higher-dimension connected n-faces");
/* FIXME: Implement other neighborhoods (and windows) and
corresponding iterators for complex-based images.
--
1.6.0.1
1
0
2604: Have tests/morpho/complex_image_morpho.cc be more verbose/specific.
by Roland Levillain 18 Oct '08
by Roland Levillain 18 Oct '08
18 Oct '08
* tests/morpho/complex_image_morpho.cc (test_morpho): Take an
extra argument to accept a textual comment (to be displayed).
(main): Adjust.
---
milena/ChangeLog | 8 ++++++++
milena/tests/morpho/complex_image_morpho.cc | 21 ++++++++++++++-------
2 files changed, 22 insertions(+), 7 deletions(-)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index 76648e0..2959330 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,5 +1,13 @@
2008-10-18 Roland Levillain <roland(a)lrde.epita.fr>
+ Have tests/morpho/complex_image_morpho.cc be more verbose/specific.
+
+ * tests/morpho/complex_image_morpho.cc (test_morpho): Take an
+ extra argument to accept a textual comment (to be displayed).
+ (main): Adjust.
+
+2008-10-18 Roland Levillain <roland(a)lrde.epita.fr>
+
Factor tests/core/image/complex_image.cc.
* tests/core/image/complex_image.cc (test_neighborhood): New
diff --git a/milena/tests/morpho/complex_image_morpho.cc b/milena/tests/morpho/complex_image_morpho.cc
index e3823c7..bcf74bd 100644
--- a/milena/tests/morpho/complex_image_morpho.cc
+++ b/milena/tests/morpho/complex_image_morpho.cc
@@ -50,7 +50,8 @@
// Forward declaration.
template <typename I, typename W>
-void test_morpho(const mln::Image<I>& ima, const mln::Window<W> win);
+void test_morpho(const mln::Image<I>& ima, const mln::Window<W> win,
+ const std::string& comment);
int main()
@@ -154,9 +155,12 @@ int main()
| Morphological operations on complex-based images. |
`---------------------------------------------------*/
- test_morpho(ima, complex_lower_window_p<D, G>());
- test_morpho(ima, complex_higher_window_p<D, G>());
- test_morpho(ima, complex_lower_higher_window_p<D, G>());
+ test_morpho(ima, complex_lower_window_p<D, G>(),
+ "lower-dimension faces");
+ test_morpho(ima, complex_higher_window_p<D, G>(),
+ "higher-dimension faces");
+ test_morpho(ima, complex_lower_higher_window_p<D, G>(),
+ "lower- and higer-dimension faces");
/* FIXME: Exercise elementary erosion/dilation (with neighborhoods)
when available. */
@@ -165,7 +169,8 @@ int main()
template <typename I, typename W>
void
-test_morpho(const mln::Image<I>& ima_, const mln::Window<W> win)
+test_morpho(const mln::Image<I>& ima_, const mln::Window<W> win,
+ const std::string& comment)
{
const I& ima = exact(ima_);
mln_assertion(ima.has_data());
@@ -173,13 +178,15 @@ test_morpho(const mln::Image<I>& ima_, const mln::Window<W> win)
mln_concrete(I) ima_dil = mln::morpho::dilation(ima, win);
// Manual iteration over the domain of IMA_DIL.
+ std::cout << "Dilation using " << comment << ":" << std::endl;
for_all (p)
- std::cout << "ima_dil (" << p << ") = " << ima_dil(p) << std::endl;
+ std::cout << " ima_dil (" << p << ") = " << ima_dil(p) << std::endl;
std::cout << std::endl;
+ std::cout << "Erosion using " << comment << ":" << std::endl;
mln_concrete(I) ima_ero = mln::morpho::erosion(ima, win);
// Manual iteration over the domain of IMA_ERO.
for_all (p)
- std::cout << "ima_ero (" << p << ") = " << ima_ero(p) << std::endl;
+ std::cout << " ima_ero (" << p << ") = " << ima_ero(p) << std::endl;
std::cout << std::endl << std::endl;
}
--
1.6.0.1
1
0
* tests/core/image/complex_image.cc (test_neighborhood): New
function.
Use it...
(main): ...here, to factor tests on iterations on neighborhoods.
---
milena/ChangeLog | 9 +++
milena/tests/core/image/complex_image.cc | 101 +++++++++++-------------------
2 files changed, 45 insertions(+), 65 deletions(-)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index ca2efe9..76648e0 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,3 +1,12 @@
+2008-10-18 Roland Levillain <roland(a)lrde.epita.fr>
+
+ Factor tests/core/image/complex_image.cc.
+
+ * tests/core/image/complex_image.cc (test_neighborhood): New
+ function.
+ Use it...
+ (main): ...here, to factor tests on iterations on neighborhoods.
+
2008-10-17 Guillaume Lazzara <z(a)lrde.epita.fr>
Add "essential" headers.
diff --git a/milena/tests/core/image/complex_image.cc b/milena/tests/core/image/complex_image.cc
index a2252ad..36028fc 100644
--- a/milena/tests/core/image/complex_image.cc
+++ b/milena/tests/core/image/complex_image.cc
@@ -44,6 +44,12 @@
construction of the complex), since it exercises too many features
in a single file. */
+// Forward declaration.
+template <typename I, typename N>
+void
+test_neighborhood(const mln::Image<I>& ima_, const mln::Neighborhood<N> nbh,
+ const std::string& comment);
+
int main()
{
@@ -217,72 +223,13 @@ int main()
// Iterators on neighborhoods. //
// ---------------------------- //
- // FIXME: Factor: these three test cases only differ by their
- // neighborhoods.
-
- // Iterate on the lower-dimension faces of each face.
- {
- typedef complex_lower_neighborhood<D, G> nbh_t;
- nbh_t nbh;
- mln_fwd_niter_(nbh_t) fn(nbh, fp);
- mln_bkd_niter_(nbh_t) bn(nbh, fp);
- for_all(fp)
- {
- std::cout << "Lower-dimension faces adjacent to " << fp << std::endl;
- for_all_2(fn, bn)
- {
- mln_assertion((fn.center() ==
- static_cast<const complex_psite<D, G>&>(fp)));
- mln_assertion((bn.center() ==
- static_cast<const complex_psite<D, G>&>(fp)));
- std::cout << " " << fn << '\t' << bn << std::endl;
- }
- }
- std::cout << std::endl;
- }
-
- // Iterate on the higher-dimension faces of each face.
- {
- typedef complex_higher_neighborhood<D, G> nbh_t;
- nbh_t nbh;
- mln_fwd_niter_(nbh_t) fn(nbh, fp);
- mln_bkd_niter_(nbh_t) bn(nbh, fp);
- for_all(fp)
- {
- std::cout << "Higher-dimension faces adjacent to " << fp << std::endl;
- for_all_2(fn, bn)
- {
- mln_assertion((fn.center() ==
- static_cast<const complex_psite<D, G>&>(fp)));
- mln_assertion((bn.center() ==
- static_cast<const complex_psite<D, G>&>(fp)));
- std::cout << " " << fn << '\t' << bn << std::endl;
- }
- }
- std::cout << std::endl;
- }
- // Iterate on the lower- and higher-dimension faces of each face.
- {
- typedef complex_lower_higher_neighborhood<D, G> nbh_t;
- nbh_t nbh;
- mln_fwd_niter_(nbh_t) fn(nbh, fp);
- mln_bkd_niter_(nbh_t) bn(nbh, fp);
- for_all(fp)
- {
- std::cout << "Lower- and higer-dimension faces adjacent to " << fp
- << std::endl;
- for_all_2(fn, bn)
- {
- mln_assertion((fn.center() ==
- static_cast<const complex_psite<D, G>&>(fp)));
- mln_assertion((bn.center() ==
- static_cast<const complex_psite<D, G>&>(fp)));
- std::cout << " " << fn << '\t' << bn << std::endl;
- }
- }
- std::cout << std::endl;
- }
+ test_neighborhood(ima, complex_lower_neighborhood<D, G>(),
+ "Lower-dimension faces");
+ test_neighborhood(ima, complex_higher_neighborhood<D, G>(),
+ "Higher-dimension faces");
+ test_neighborhood(ima, complex_lower_higher_neighborhood<D, G>(),
+ "Lower- and higer-dimension faces");
/* FIXME: Implement other neighborhoods (and windows) and
@@ -313,3 +260,27 @@ int main()
See also https://trac.lrde.org/olena/ticket/162. */
}
+
+
+template <typename I, typename N>
+void
+test_neighborhood(const mln::Image<I>& ima_, const mln::Neighborhood<N> nbh,
+ const std::string& comment)
+{
+ const I& ima = exact(ima_);
+ mln_fwd_piter(I) fp(ima.domain());
+
+ mln_fwd_niter(N) fn(nbh, fp);
+ mln_bkd_niter(N) bn(nbh, fp);
+ for_all(fp)
+ {
+ std::cout << comment << " adjacent to " << fp << std::endl;
+ for_all_2(fn, bn)
+ {
+ mln_assertion((fn.center() == static_cast<const mln_psite(I)&>(fp)));
+ mln_assertion((bn.center() == static_cast<const mln_psite(I)&>(fp)));
+ std::cout << " " << fn << '\t' << bn << std::endl;
+ }
+ }
+ std::cout << std::endl;
+}
--
1.6.0.1
1
0
#142: Add iterators on graphs
----------------------+-----------------------------------------------------
Reporter: levill_r | Owner: levill_r
Type: task | Status: new
Priority: major | Milestone: Olena 1.0
Component: Milena | Version: 1.0
Keywords: |
----------------------+-----------------------------------------------------
We need these, at least:
* iterator on vertices (forward, backward)
* iterator on edges (forward, backward)
* iterator on the adjacent edges of a vertex (forward, backward)
* iterator on the adjacent edges of an edge (forward, backward)
--
Ticket URL: <https://trac.lrde.org/olena/ticket/142>
Olena <http://olena.lrde.epita.fr>
Olena, a generic and efficient C++ image processing library.
2
3
#80: Olena 1.0 User Documentation
-----------------------+----------------------------------------------------
Reporter: levill_r | Owner: Olena Team
Type: task | Status: new
Priority: major | Milestone: Olena 1.0
Component: Milena | Version: 1.0
Resolution: | Keywords: vaucanson doc
-----------------------+----------------------------------------------------
Comment (by lazzara):
Now, all symbols in a namespace 'internal' or ending with a '_' won't be
included in the user doc.
--
Ticket URL: <https://trac.lrde.org/olena/ticket/80#comment:6>
Olena <http://olena.lrde.epita.fr>
Olena, a generic and efficient C++ image processing library.
1
0
---
ChangeLog | 81 -------------------------------------
milena/ChangeLog | 101 ++++++++++++++++++++++++++++++++++++++++++++--
milena/sandbox/ChangeLog | 14 ++++++
3 files changed, 111 insertions(+), 85 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 091cbe8..069fd6c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,88 +1,7 @@
-2008-17-07 Guillaume Lazzara <z(a)lrde.epita.fr>
-
- Get and display character bboxes.
- * milena/sandbox/scribo/demat.hh: update.
- Does not create text bboxes yet.
-
-2008-17-07 Guillaume Lazzara <z(a)lrde.epita.fr>
-
- Add "essential" headers.
- * milena/mln/essential/1d.hh,
- * milena/mln/essential/2d.hh,
- * milena/mln/essential/3d.hh:
- First version of these headers. Will be automatically generated in a
- near future.
-
-2008-17-07 Guillaume Lazzara <z(a)lrde.epita.fr>
-
- Refactor graph iterator classes.
- * milena/mln/util/internal/graph_edge.hh: add invalidate().
-
- * milena/mln/util/internal/graph_iter_base.hh: Base implementation for
- a graph iterator.
-
- * milena/mln/util/internal/graph_vertex_iter.hh,
- * milena/mln/util/internal/graph_edge_iter.hh: content moved...
- * milena/mln/util/internal/graph_iter.hh: ...here.
-
- * milena/mln/util/internal/graph_nbh_iter.hh: Base implementation for
- a graph iterator on a edge/vertex neighborhood.
-
- * milena/mln/util/internal/graph_edge_nbh_edge_iter.hh,
- * milena/mln/util/internal/graph_vertex_nbh_edge_iter.hh,
- * milena/mln/util/internal/graph_vertex_nbh_vertex_iter.hh: content
- moved...
- * milena/mln/util/internal/graph_nbh_iter_base.hh: ...here.
-
- * milena/mln/util/graph.hh: update includes.
-
-2008-17-07 Guillaume Lazzara <z(a)lrde.epita.fr>
-
- Use track_ptr in graph.
- * milena/mln/core/concept/graph.hh,
- * milena/util/graph.hh,
- * milena/util/internal/graph_base.hh,
- * milena/util/internal/graph_edge.hh,
- * milena/util/internal/graph_edge_iter.hh,
- * milena/util/internal/graph_edge_nbh_edge_iter.hh,
- * milena/util/internal/graph_vertex.hh,
- * milena/util/internal/graph_vertex_iter.hh,
- * milena/util/internal/graph_vertex_nbh_edge_iter.hh,
- * milena/util/internal/graph_vertex_nbh_vertex_iter.hh:
- Share data between graphs.
- Refactor some parts of the code.
-
-2008-17-07 Guillaume Lazzara <z(a)lrde.epita.fr>
-
- Add sample code for the tutorial.
- * milena/mln/doc/tutorial/samples/borderthickness-output.tex,
- * milena/mln/doc/tutorial/samples/borderthickness.tex,
- * milena/mln/doc/tutorial/samples/extension-ignore.tex,
- * milena/mln/doc/tutorial/samples/extension-ignore2.tex,
- * milena/mln/doc/tutorial/samples/ima-load.tex,
- * milena/mln/doc/tutorial/samples/ima-save.tex,
- * milena/mln/doc/tutorial/samples/ima-size-output.tex,
- * milena/mln/doc/tutorial/samples/ima-size.tex,
- * milena/mln/doc/tutorial/samples/ima2d-1-output.tex,
- * milena/mln/doc/tutorial/samples/ima2d-3-output.tex,
- * milena/mln/doc/tutorial/samples/paste-call-1-output.tex,
- * milena/mln/doc/tutorial/samples/point-1-output.tex,
- * milena/mln/doc/tutorial/tutorial.tex:
- Add these sample codes for the tutorial.
-
-
2008-10-15 Roland Levillain <roland(a)lrde.epita.fr>
* configure.ac: Configure milena/tests/io/off/Makefile.
-2008-16-07 Guillaume Lazzara <z(a)lrde.epita.fr>
-
- Fix ambiguous namespaces.
- * milena/mln/level/fill_with_image.hh
- * milena/mln/level/paste.hh:
- Fix compilation error. It could not resolve the correct namespace
- path.
-
2008-09-24 Roland Levillain <roland(a)lrde.epita.fr>
* configure.ac: Configure milena/tests/topo/Makefile.
diff --git a/milena/ChangeLog b/milena/ChangeLog
index 8aeb1dc..ca2efe9 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,3 +1,74 @@
+2008-10-17 Guillaume Lazzara <z(a)lrde.epita.fr>
+
+ Add "essential" headers.
+
+ * mln/essential/1d.hh,
+ * mln/essential/2d.hh,
+ * mln/essential/3d.hh:
+ First version of these headers. Will be automatically generated in a
+ near future.
+
+2008-10-17 Guillaume Lazzara <z(a)lrde.epita.fr>
+
+ Refactor graph iterator classes.
+
+ * mln/util/internal/graph_edge.hh: add invalidate().
+
+ * mln/util/internal/graph_iter_base.hh: Base implementation for
+ a graph iterator.
+
+ * mln/util/internal/graph_vertex_iter.hh,
+ * mln/util/internal/graph_edge_iter.hh: content moved...
+ * mln/util/internal/graph_iter.hh: ...here.
+
+ * mln/util/internal/graph_nbh_iter.hh: Base implementation for
+ a graph iterator on a edge/vertex neighborhood.
+
+ * mln/util/internal/graph_edge_nbh_edge_iter.hh,
+ * mln/util/internal/graph_vertex_nbh_edge_iter.hh,
+ * mln/util/internal/graph_vertex_nbh_vertex_iter.hh: content
+ moved...
+ * mln/util/internal/graph_nbh_iter_base.hh: ...here.
+
+ * mln/util/graph.hh: update includes.
+
+2008-10-17 Guillaume Lazzara <z(a)lrde.epita.fr>
+
+ Use track_ptr in graph.
+
+ * mln/core/concept/graph.hh,
+ * util/graph.hh,
+ * util/internal/graph_base.hh,
+ * util/internal/graph_edge.hh,
+ * util/internal/graph_edge_iter.hh,
+ * util/internal/graph_edge_nbh_edge_iter.hh,
+ * util/internal/graph_vertex.hh,
+ * util/internal/graph_vertex_iter.hh,
+ * util/internal/graph_vertex_nbh_edge_iter.hh,
+ * util/internal/graph_vertex_nbh_vertex_iter.hh:
+ Share data between graphs.
+ Refactor some parts of the code.
+
+2008-10-17 Guillaume Lazzara <z(a)lrde.epita.fr>
+
+ Add sample code for the tutorial.
+
+ * mln/doc/tutorial/samples/borderthickness-output.tex,
+ * mln/doc/tutorial/samples/borderthickness.tex,
+ * mln/doc/tutorial/samples/extension-ignore.tex,
+ * mln/doc/tutorial/samples/extension-ignore2.tex,
+ * mln/doc/tutorial/samples/ima-load.tex,
+ * mln/doc/tutorial/samples/ima-save.tex,
+ * mln/doc/tutorial/samples/ima-size-output.tex,
+ * mln/doc/tutorial/samples/ima-size.tex,
+ * mln/doc/tutorial/samples/ima2d-1-output.tex,
+ * mln/doc/tutorial/samples/ima2d-3-output.tex,
+ * mln/doc/tutorial/samples/paste-call-1-output.tex,
+ * mln/doc/tutorial/samples/point-1-output.tex,
+ * mln/doc/tutorial/tutorial.tex:
+ Add these sample codes for the tutorial.
+
+
2008-10-17 Roland Levillain <roland(a)lrde.epita.fr>
Move site_pair into namespace mln::util.
@@ -67,6 +138,15 @@
* mln/core/internal/complex_neighborhood_base.hh: New.
+2008-10-16 Guillaume Lazzara <z(a)lrde.epita.fr>
+
+ Fix ambiguous namespaces.
+
+ * mln/level/fill_with_image.hh
+ * mln/level/paste.hh:
+ Fix compilation error. It could not resolve the correct namespace
+ path.
+
2008-10-16 Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
Fix some morpho operators.
@@ -255,9 +335,10 @@
* mln/core/def/coordf.hh: New.
-2008-16-07 Guillaume Lazzara <z(a)lrde.epita.fr>
+2008-10-16 Guillaume Lazzara <z(a)lrde.epita.fr>
Update tutorial.
+
* doc/tutorial/samples/ima2d-1.tex,
* doc/tutorial/samples/ima2d-3.tex,
* doc/tutorial/samples/paste-call-1.tex,
@@ -268,7 +349,9 @@
Mainly update image chapter.
Cleanup source.
-2008-15-07 Guillaume Lazzara <z(a)lrde.epita.fr>
+2008-10-15 Guillaume Lazzara <z(a)lrde.epita.fr>
+
+ Update tutorial.
* mln/doc/tutorial/samples/box2d-1.tex,
* mln/doc/tutorial/samples/box2d-2.tex,
@@ -315,11 +398,11 @@
2008-10-15 Guillaume Lazzara <z(a)lrde.epita.fr>
Update the prototype of labeling::compute().
+
* mln/labeling/compute.hh: change the return type to an
util::array.
- * sandbox/scribo/demat.hh,
- * tests/labeling/compute.cc: update according the new
+ * mln/tests/labeling/compute.cc: update according the new
prototype.
2008-10-15 Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
@@ -345,6 +428,7 @@
2008-10-15 Guillaume Lazzara <z(a)lrde.epita.fr>
Remove the useless '_' postfix in all the accumulators.
+
* doc/examples/tuto_bis.cc,
* doc/tutorial/examples/accu.cc,
* mln/accu/bbox.hh,
@@ -422,6 +506,7 @@
2008-10-15 Guillaume Lazzara <z(a)lrde.epita.fr>
Update accus to make them work with the new q_result typedef.
+
* mln/accu/bbox.hh,
* mln/accu/histo.hh,
* mln/accu/max.hh,
@@ -478,6 +563,7 @@
2008-10-14 Guillaume Lazzara <z(a)lrde.epita.fr>
Fix labeling::compute return type.
+
* mln/labeling/compute.hh: Fix many compilation errors
while taking directly the result type of an accumulator as a template
parameter for p_array<>.
@@ -486,12 +572,14 @@
2008-10-14 Guillaume Lazzara <z(a)lrde.epita.fr>
Add meta-accumulator for accu::bbox.
+
* mln/accu/bbox.hh: add missing meta-accumulator.
2008-10-14 Guillaume Lazzara <z(a)lrde.epita.fr>
Add is_valid() in the accumulator concept and move meta-accumulators
in meta namespace.
+
* mln/accu/count.hh,
* mln/accu/height.hh,
* mln/accu/histo.hh,
@@ -529,6 +617,7 @@
2008-10-14 Guillaume Lazzara <z(a)lrde.epita.fr>
Add labeling::compute.
+
* mln/labeling/compute.hh: do it.
* tests/labeling/Makefile.am,
* tests/labeling/compute.cc: Add the proper test.
@@ -536,6 +625,7 @@
2008-10-14 Guillaume Lazzara <z(a)lrde.epita.fr>
Use geom::bbox instead of bbox().
+
* mln/geom/max_col.hh,
* mln/geom/max_row.hh,
* mln/geom/min_col.hh,
@@ -722,6 +812,7 @@
2008-10-07 Guillaume Lazzara <z(a)lrde.epita.fr>
Fix most of the doxygen warnings.
+
* mln/arith/min.hh,
* mln/arith/plus.hh,
* mln/core/concept/doc/point_iterator.hh,
@@ -1092,6 +1183,7 @@
2008-10-03 Guillaume Lazzara <z(a)lrde.epita.fr>
Various small fixes.
+
* mln/algebra/vec.hh: add missing header.
* mln/core/image/obased_rle_image.hh,
@@ -1112,6 +1204,7 @@
2008-10-03 Guillaume Lazzara <z(a)lrde.epita.fr>
Update tutorial..
+
* doc/tutorial/tutorial.tex:
- Add a new section about sites
- Add new subsections about image domain and values.
diff --git a/milena/sandbox/ChangeLog b/milena/sandbox/ChangeLog
index 00cf46e..a6a5fa4 100644
--- a/milena/sandbox/ChangeLog
+++ b/milena/sandbox/ChangeLog
@@ -1,3 +1,17 @@
+2008-10-17 Guillaume Lazzara <z(a)lrde.epita.fr>
+
+ Get and display character bboxes.
+
+ * sandbox/scribo/demat.hh: update.
+ Does not create text bboxes yet.
+
+2008-10-15 Guillaume Lazzara <z(a)lrde.epita.fr>
+
+ Update the prototype of labeling::compute().
+
+ * sandbox/scribo/demat.hh: update according the new
+ prototype.
+
2008-10-15 Ugo Jardonnet <ugo.jardonnet(a)lrde.epita.fr>
INIM Classification++.
--
1.5.6.5
1
0
---
ChangeLog | 6 ++
milena/sandbox/scribo/demat.hh | 118 +++++++++++++++++++++++++++++-----------
2 files changed, 92 insertions(+), 32 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 442b848..091cbe8 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,11 @@
2008-17-07 Guillaume Lazzara <z(a)lrde.epita.fr>
+ Get and display character bboxes.
+ * milena/sandbox/scribo/demat.hh: update.
+ Does not create text bboxes yet.
+
+2008-17-07 Guillaume Lazzara <z(a)lrde.epita.fr>
+
Add "essential" headers.
* milena/mln/essential/1d.hh,
* milena/mln/essential/2d.hh,
diff --git a/milena/sandbox/scribo/demat.hh b/milena/sandbox/scribo/demat.hh
index 7a35ee9..742143d 100644
--- a/milena/sandbox/scribo/demat.hh
+++ b/milena/sandbox/scribo/demat.hh
@@ -32,31 +32,48 @@
# include <mln/core/image/image_if.hh>
# include <mln/core/image/sub_image.hh>
+# include <mln/core/image/cast_image.hh>
# include <mln/core/alias/neighb2d.hh>
# include <mln/core/var.hh>
+# include <mln/core/routine/clone.hh>
+# include <mln/core/routine/ops.hh>
# include <mln/core/site_set/p_vaccess.hh>
+# include <mln/accu/bbox.hh>
+
# include <mln/binarization/threshold.hh>
-# include <mln/morpho/hit_or_miss.hh>
-# include <mln/level/fill.hh>
+
# include <mln/border/fill.hh>
+
+# include <mln/convert/to.hh>
+# include <mln/convert/to_fun.hh>
+
+# include <mln/debug/println.hh>
+
+# include <mln/draw/box.hh>
+
+# include <mln/estim/nsites.hh>
+
# include <mln/io/pbm/load.hh>
# include <mln/io/pgm/load.hh>
# include <mln/io/pbm/save.hh>
# include <mln/io/pgm/save.hh>
-# include <mln/debug/println.hh>
-# include <mln/morpho/opening.hh>
-# include <mln/trait/value_.hh>
-# include <mln/value/int_u8.hh>
-# include <mln/level/paste.hh>
+
# include <mln/labeling/blobs.hh>
+# include <mln/labeling/compute.hh>
+
# include <mln/level/fill.hh>
+# include <mln/level/paste.hh>
+
+# include <mln/morpho/hit_or_miss.hh>
+# include <mln/morpho/opening.hh>
+
# include <mln/pw/all.hh>
-# include <mln/convert/to_fun.hh>
-# include <mln/geom/bbox.hh>
-# include <mln/labeling/compute.hh>
-# include <mln/accu/bbox.hh>
+# include <mln/util/array.hh>
+
+# include <mln/value/int_u16.hh>
+# include <mln/value/rgb8.hh>
namespace scribo
{
@@ -64,43 +81,78 @@ namespace scribo
namespace internal
{
- void filter_image(mln::image2d<bool>& ima,
- const mln::image2d<bool>& filter,
- unsigned bbox_larger)
- {
- using namespace mln;
- using value::int_u8;
+ using namespace mln;
+ using value::int_u16;
- typedef image2d<int_u8> I;
- typedef mln_accu_with_(accu::meta::bbox, mln_psite_(I)) A;
- typedef util::array<A::result> boxes_t;
+ util::array<box2d>
+ component_boxes(const image2d<bool>& filter)
+ {
- int_u8 nlabels;
- I lbl = labeling::blobs(filter, c4(), nlabels);
+ int_u16 nlabels;
+ image2d<int_u16> lbl = labeling::blobs(filter, c4(), nlabels);
- boxes_t boxes = labeling::compute(accu::meta::bbox(), lbl, nlabels);
+ return labeling::compute(accu::meta::bbox(), lbl, nlabels);
+ }
- for (unsigned i = 1; i <= nlabels; ++i)
+ void erase_boxes(image2d<bool>& ima,
+ const util::array<box2d>& boxes,
+ unsigned bbox_larger)
+ {
+ for (unsigned i = 1; i <= boxes.nelements(); ++i)
level::paste(pw::cst(false)
- | boxes[i].to_larger(bbox_larger),
- ima);
+ | boxes[i].to_larger(bbox_larger),
+ ima);
}
- void remove_tables(mln::image2d<bool>& in, unsigned h, unsigned w, unsigned n)
+
+ std::pair<util::array<box2d>,
+ util::array<box2d> >
+ extract_tables(image2d<bool>& in, unsigned h, unsigned w, unsigned n)
{
- using namespace mln;
+ typedef image2d<int_u16> I;
+ typedef accu::bbox<mln_psite_(I)> A;
+ typedef util::array<mln_result_(A)> boxes_t;
// Lignes verticales
win::rectangle2d vwin(h, w);
image2d<bool> vfilter = morpho::opening(in, vwin);
io::pbm::save(vfilter, "./table-vfilter.pbm");
- filter_image(in, vfilter, n);
+ boxes_t vboxes = component_boxes(vfilter);
+ erase_boxes(in, vboxes, n);
// Lignes horizontales
win::rectangle2d hwin(w, h);
image2d<bool> hfilter = morpho::opening(in, hwin);
io::pbm::save(hfilter, "./table-hfilter.pbm");
- filter_image(in, hfilter, n);
+ boxes_t hboxes = component_boxes(hfilter);
+ erase_boxes(in, hboxes, n);
+
+ return std::make_pair(vboxes, hboxes);
+ }
+
+ void
+ extract_text(image2d<bool>& in)
+ {
+ typedef image2d<int_u16> I;
+ typedef util::array<box2d> boxes_t;
+
+ boxes_t tboxes = component_boxes(in);
+
+ //FIXME: don't know how to clone and convert to image<int> properly
+ // \{
+ I ima(in.domain());
+ level::paste(in, ima);
+ level::paste(pw::cst(100)
+ | (in | (pw::value(in) == pw::cst(true))).domain(), ima);
+ // \}
+
+ for (int i = 1; i < tboxes.nelements(); ++i)
+ if (estim::nsites(tboxes[i]) < 40)
+ level::paste(pw::cst(false) | tboxes[i], ima);
+ else
+ draw::box(ima, tboxes[i], 150u);
+
+ io::pgm::save(ima, "./text.pgm");
}
} // end of namespace scribo::internal
@@ -111,7 +163,7 @@ namespace scribo
void demat(char *argv[])
{
using namespace mln;
- using value::int_u8;
+ border::thickness = 0;
//Useful debug variables
unsigned h = atoi(argv[2]);
@@ -122,9 +174,11 @@ namespace scribo
image2d<bool> in;
io::pbm::load(in, argv[1]);
- internal::remove_tables(in, h, w, n);
+ internal::extract_tables(in, h, w, n);
io::pbm::save(in, "./table-filtered.pbm");
+
+ internal::extract_text(in);
}
} // end of namespace scribo
--
1.5.6.5
1
0
---
ChangeLog | 9 ++++++
milena/mln/essential/1d.hh | 49 ++++++++++++++++++++++++++++++++
milena/mln/essential/2d.hh | 66 ++++++++++++++++++++++++++++++++++++++++++++
milena/mln/essential/3d.hh | 49 ++++++++++++++++++++++++++++++++
4 files changed, 173 insertions(+), 0 deletions(-)
create mode 100644 milena/mln/essential/1d.hh
create mode 100644 milena/mln/essential/2d.hh
create mode 100644 milena/mln/essential/3d.hh
diff --git a/ChangeLog b/ChangeLog
index 456606f..442b848 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,14 @@
2008-17-07 Guillaume Lazzara <z(a)lrde.epita.fr>
+ Add "essential" headers.
+ * milena/mln/essential/1d.hh,
+ * milena/mln/essential/2d.hh,
+ * milena/mln/essential/3d.hh:
+ First version of these headers. Will be automatically generated in a
+ near future.
+
+2008-17-07 Guillaume Lazzara <z(a)lrde.epita.fr>
+
Refactor graph iterator classes.
* milena/mln/util/internal/graph_edge.hh: add invalidate().
diff --git a/milena/mln/essential/1d.hh b/milena/mln/essential/1d.hh
new file mode 100644
index 0000000..742a676
--- /dev/null
+++ b/milena/mln/essential/1d.hh
@@ -0,0 +1,49 @@
+// Copyright (C) 2008 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef MLN_ESSENTIAL_1D_HH_
+# define MLN_ESSENTIAL_1D_HH_
+
+# include <core/image/image1d.hh>
+# include <core/pixter1d.hh>
+# include <core/alias/box1d.hh>
+# include <core/alias/dpoint1d.hh>
+# include <core/alias/neighb1d.hh>
+# include <core/alias/point1d.hh>
+# include <core/alias/w_window1d_float.hh>
+# include <core/alias/w_window1d_int.hh>
+# include <core/alias/window1d.hh>
+# include <geom/size1d.hh>
+# include <make/box1d.hh>
+# include <make/image1d.hh>
+# include <make/w_window1d.hh>
+# include <make/w_window1d_int.hh>
+# include <metal/array1d.hh>
+# include <win/segment1d.hh>
+
+#endif // ! MLN_ESSENTIAL_1D_HH_
+
diff --git a/milena/mln/essential/2d.hh b/milena/mln/essential/2d.hh
new file mode 100644
index 0000000..e41cf4e
--- /dev/null
+++ b/milena/mln/essential/2d.hh
@@ -0,0 +1,66 @@
+// Copyright (C) 2008 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef MLN_ESSENTIAL_2D_HH_
+# define MLN_ESSENTIAL_2D_HH_
+
+# include <core/clock_neighb2d.hh>
+# include <core/image/image2d.hh>
+# include <core/image/image2d_h.hh>
+# include <core/pixter2d.hh>
+# include <core/site_set/p_line2d.hh>
+# include <core/alias/box2d.hh>
+# include <core/alias/box2d_h.hh>
+# include <core/alias/dpoint2d.hh>
+# include <core/alias/dpoint2d_h.hh>
+# include <core/alias/neighb2d.hh>
+# include <core/alias/p_run2d.hh>
+# include <core/alias/p_runs2d.hh>
+# include <core/alias/point2d.hh>
+# include <core/alias/point2d_h.hh>
+# include <core/alias/w_window2d_float.hh>
+# include <core/alias/w_window2d_int.hh>
+# include <core/alias/window2d.hh>
+# include <geom/size2d.hh>
+# include <make/box2d.hh>
+# include <make/box2d_h.hh>
+# include <make/dpoint2d_h.hh>
+# include <make/image2d.hh>
+# include <make/point2d_h.hh>
+# include <make/w_window2d.hh>
+# include <make/w_window2d_int.hh>
+# include <make/double_neighb2d.hh>
+# include <metal/array2d.hh>
+# include <win/backdiag2d.hh>
+# include <win/diag2d.hh>
+# include <win/disk2d.hh>
+# include <win/hline2d.hh>
+# include <win/octagon2d.hh>
+# include <win/rectangle2d.hh>
+# include <win/vline2d.hh>
+
+#endif // ! MLN_ESSENTIAL_3D_HH_
diff --git a/milena/mln/essential/3d.hh b/milena/mln/essential/3d.hh
new file mode 100644
index 0000000..d413211
--- /dev/null
+++ b/milena/mln/essential/3d.hh
@@ -0,0 +1,49 @@
+// Copyright (C) 2008 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef MLN_ESSENTIAL_3D_HH_
+# define MLN_ESSENTIAL_3D_HH_
+
+# include <core/image/image3d.hh>
+# include <core/pixter3d.hh>
+# include <core/alias/box3d.hh>
+# include <core/alias/dpoint3d.hh>
+# include <core/alias/neighb3d.hh>
+# include <core/alias/point3d.hh>
+# include <core/alias/w_window3d_float.hh>
+# include <core/alias/w_window3d_int.hh>
+# include <core/alias/window3d.hh>
+# include <geom/size3d.hh>
+# include <make/box3d.hh>
+# include <make/w_window3d.hh>
+# include <make/w_window3d_int.hh>
+# include <metal/array3d.hh>
+# include <win/cube3d.hh>
+# include <win/cuboid3d.hh>
+
+#endif // ! MLN_ESSENTIAL_3D_HH_
+
--
1.5.6.5
1
0
---
ChangeLog | 23 +
milena/mln/util/graph.hh | 8 +-
milena/mln/util/internal/graph_edge.hh | 39 +-
milena/mln/util/internal/graph_edge_iter.hh | 273 ---------
.../mln/util/internal/graph_edge_nbh_edge_iter.hh | 335 ----------
milena/mln/util/internal/graph_iter.hh | 298 +++++++++
milena/mln/util/internal/graph_iter_base.hh | 144 +++++
milena/mln/util/internal/graph_nbh_iter.hh | 636 ++++++++++++++++++++
milena/mln/util/internal/graph_nbh_iter_base.hh | 175 ++++++
milena/mln/util/internal/graph_vertex_iter.hh | 286 ---------
.../util/internal/graph_vertex_nbh_edge_iter.hh | 323 ----------
.../util/internal/graph_vertex_nbh_vertex_iter.hh | 320 ----------
12 files changed, 1309 insertions(+), 1551 deletions(-)
delete mode 100644 milena/mln/util/internal/graph_edge_iter.hh
delete mode 100644 milena/mln/util/internal/graph_edge_nbh_edge_iter.hh
create mode 100644 milena/mln/util/internal/graph_iter.hh
create mode 100644 milena/mln/util/internal/graph_iter_base.hh
create mode 100644 milena/mln/util/internal/graph_nbh_iter.hh
create mode 100644 milena/mln/util/internal/graph_nbh_iter_base.hh
delete mode 100644 milena/mln/util/internal/graph_vertex_iter.hh
delete mode 100644 milena/mln/util/internal/graph_vertex_nbh_edge_iter.hh
delete mode 100644 milena/mln/util/internal/graph_vertex_nbh_vertex_iter.hh
diff --git a/ChangeLog b/ChangeLog
index a01d9c9..456606f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,28 @@
2008-17-07 Guillaume Lazzara <z(a)lrde.epita.fr>
+ Refactor graph iterator classes.
+ * milena/mln/util/internal/graph_edge.hh: add invalidate().
+
+ * milena/mln/util/internal/graph_iter_base.hh: Base implementation for
+ a graph iterator.
+
+ * milena/mln/util/internal/graph_vertex_iter.hh,
+ * milena/mln/util/internal/graph_edge_iter.hh: content moved...
+ * milena/mln/util/internal/graph_iter.hh: ...here.
+
+ * milena/mln/util/internal/graph_nbh_iter.hh: Base implementation for
+ a graph iterator on a edge/vertex neighborhood.
+
+ * milena/mln/util/internal/graph_edge_nbh_edge_iter.hh,
+ * milena/mln/util/internal/graph_vertex_nbh_edge_iter.hh,
+ * milena/mln/util/internal/graph_vertex_nbh_vertex_iter.hh: content
+ moved...
+ * milena/mln/util/internal/graph_nbh_iter_base.hh: ...here.
+
+ * milena/mln/util/graph.hh: update includes.
+
+2008-17-07 Guillaume Lazzara <z(a)lrde.epita.fr>
+
Use track_ptr in graph.
* milena/mln/core/concept/graph.hh,
* milena/util/graph.hh,
diff --git a/milena/mln/util/graph.hh b/milena/mln/util/graph.hh
index 765c07c..aecb8e9 100644
--- a/milena/mln/util/graph.hh
+++ b/milena/mln/util/graph.hh
@@ -32,11 +32,8 @@
/// \brief Definitions of undirected graphs.
# include <mln/util/internal/graph_base.hh>
-# include <mln/util/internal/graph_vertex_iter.hh>
-# include <mln/util/internal/graph_edge_iter.hh>
-# include <mln/util/internal/graph_vertex_nbh_vertex_iter.hh>
-# include <mln/util/internal/graph_vertex_nbh_edge_iter.hh>
-# include <mln/util/internal/graph_edge_nbh_edge_iter.hh>
+# include <mln/util/internal/graph_iter.hh>
+# include <mln/util/internal/graph_nbh_iter_base.hh>
# include <mln/util/ord_pair.hh>
namespace mln
@@ -48,6 +45,7 @@ namespace mln
class graph;
}
+
namespace internal
{
diff --git a/milena/mln/util/internal/graph_edge.hh b/milena/mln/util/internal/graph_edge.hh
index dcbf6ac..42d0e62 100644
--- a/milena/mln/util/internal/graph_edge.hh
+++ b/milena/mln/util/internal/graph_edge.hh
@@ -62,6 +62,11 @@ namespace mln
/// Misc.
/// \{
+ /// Return whether is points to a known edge.
+ bool is_valid() const;
+ /// Invalidate that vertex.
+ void invalidate();
+
/// Return the edge id.
unsigned id() const;
@@ -86,8 +91,6 @@ namespace mln
/// Edge oriented.
/// \{
- bool is_valid() const;
-
/// Return the lowest vertex id adjacent to this edge.
unsigned v1() const;
@@ -145,6 +148,7 @@ namespace mln
{
void update_id(unsigned id);
void change_graph(const mlc_const(G)& g);
+ void invalidate();
private:
E& exact_();
@@ -219,19 +223,28 @@ namespace mln
template <typename G>
inline
- unsigned
- edge<G>::v_other(unsigned id_v) const
+ bool
+ edge<G>::is_valid() const
{
- mln_precondition(v1() == id_v || v2() == id_v);
- return g_.v_other(id_, id_v);
+ return g_.has_e(id_);
}
template <typename G>
inline
- bool
- edge<G>::is_valid() const
+ void
+ edge<G>::invalidate()
{
- return g_.has_e(id_);
+ id_ = g_.e_nmax();
+ }
+
+
+ template <typename G>
+ inline
+ unsigned
+ edge<G>::v_other(unsigned id_v) const
+ {
+ mln_precondition(v1() == id_v || v2() == id_v);
+ return g_.v_other(id_, id_v);
}
template <typename G>
@@ -390,6 +403,14 @@ namespace mln
return exact_().get_subject().change_graph(g);
}
+ template <typename G, typename E>
+ inline
+ void
+ subject_impl< util::edge<G>, E >::invalidate()
+ {
+ return exact_().get_subject().invalidate();
+ }
+
} // End of namespace mln::internal
# endif // !MLN_INCLUDE_ONLY
diff --git a/milena/mln/util/internal/graph_edge_iter.hh b/milena/mln/util/internal/graph_edge_iter.hh
deleted file mode 100644
index b3d83de..0000000
--- a/milena/mln/util/internal/graph_edge_iter.hh
+++ /dev/null
@@ -1,273 +0,0 @@
-// Copyright (C) 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
-// of the GNU General Public License version 2 as published by the
-// Free Software Foundation.
-//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this library; see the file COPYING. If not, write to
-// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
-// Boston, MA 02111-1307, USA.
-//
-// As a special exception, you may use this file as part of a free
-// software library without restriction. Specifically, if other files
-// instantiate templates or use macros or inline functions from this
-// file, or you compile this file and link it with other files to
-// produce an executable, this file does not by itself cause the
-// resulting executable to be covered by the GNU General Public
-// License. This exception does not however invalidate any other
-// reasons why the executable file might be covered by the GNU General
-// Public License.
-
-#ifndef MLN_UTIL_INTERNAL_GRAPH_EDGE_ITER_HH
-# define MLN_UTIL_INTERNAL_GRAPH_EDGE_ITER_HH
-
-# include <mln/core/concept/iterator.hh>
-# include <mln/core/concept/proxy.hh>
-# include <mln/util/internal/graph_edge.hh>
-
-/// \file mln/util/internal/graph_edge_iter.hh
-/// \brief Implementation for graph edge iterators.
-
-namespace mln
-{
-
- namespace internal
- {
-
- /// Forward edge iterator.
- template <typename G>
- class edge_fwd_iterator
- : public Proxy< edge_fwd_iterator<G> >,
- public internal::proxy_impl< const util::edge<G>&, edge_fwd_iterator<G> >
- {
- public:
- /// Constructors.
- /// \{
- edge_fwd_iterator();
- edge_fwd_iterator(const G& g);
- /// \}
-
- /// Iterator interface
- /// \{
- /// Test if the iterator is valid.
- bool is_valid() const;
- /// Invalidate the iterator.
- void invalidate();
-
- /// Start an iteration.
- void start();
-
- /// Go to the next value.
- void next();
-
- /// Return current index
- unsigned index() const;
- /// \}
-
- /// Proxy.
- /// \{
- /// Proxy subject
- const util::edge<G>& subj_();
- /// \}
-
- protected:
- util::edge<G> e_;
- };
-
- template <typename G>
- class edge_bkd_iterator
- : public Proxy< edge_bkd_iterator<G> >,
- public proxy_impl< const util::edge<G>&, edge_bkd_iterator<G> >
- {
- public:
- /// Constructors.
- /// \{
- edge_bkd_iterator();
- edge_bkd_iterator(const G& g);
- /// \}
-
- /// Iterator interface.
- /// \{
- /// Test if the iterator is valid.
- bool is_valid() const;
- /// Invalidate the iterator.
- void invalidate();
-
- /// Start an iteration.
- void start();
-
- /// Go to the next value.
- void next();
-
- /// Return current index
- unsigned index() const;
- /// \}
-
- /// Proxy.
- /// \{
- /// Proxy subject
- const util::edge<G>& subj_();
- /// \}
-
- protected:
- util::edge<G> e_;
- };
-
- } // End of namespace mln::internal
-
-} // End of namespace mln
-
-
-# ifndef MLN_INCLUDE_ONLY
-
-namespace mln
-{
-
- namespace internal
- {
-
- template <typename G>
- inline
- edge_fwd_iterator<G>::edge_fwd_iterator()
- {
- }
-
- template <typename G>
- inline
- edge_fwd_iterator<G>::edge_fwd_iterator(const G& g)
- : e_(util::edge<G>(g))
- {
- invalidate();
- }
-
- template <typename G>
- inline
- bool
- edge_fwd_iterator<G>::is_valid() const
- {
- return e_.is_valid();
- }
-
- template <typename G>
- inline
- void
- edge_fwd_iterator<G>::invalidate()
- {
- e_.update_id(e_.g().e_nmax());
- }
-
- template <typename G>
- inline
- void
- edge_fwd_iterator<G>::start()
- {
- e_.update_id(0);
- }
-
- template <typename G>
- inline
- void
- edge_fwd_iterator<G>::next()
- {
- e_.update_id(e_.id() + 1);
- }
-
- template <typename G>
- inline
- unsigned
- edge_fwd_iterator<G>::index() const
- {
- return e_.id();
- }
-
- template <typename G>
- inline
- const util::edge<G>&
- edge_fwd_iterator<G>::subj_()
- {
- return e_;
- }
-
-
-
- /*------------------`
- | edge_bkd_iterator |
- \------------------*/
-
- template <typename G>
- inline
- edge_bkd_iterator<G>::edge_bkd_iterator()
- {
- }
-
- template <typename G>
- inline
- edge_bkd_iterator<G>::edge_bkd_iterator(const G& g)
- : e_(util::edge<G>(g))
- {
- invalidate();
- }
-
- template <typename G>
- inline
- bool
- edge_bkd_iterator<G>::is_valid() const
- {
- return e_.is_valid();
- }
-
- template <typename G>
- inline
- void
- edge_bkd_iterator<G>::invalidate()
- {
- e_.update_id(e_.g().e_nmax());
- }
-
- template <typename G>
- inline
- void
- edge_bkd_iterator<G>::start()
- {
- e_.update_id(e_.g().e_nmax() - 1);
- }
-
- template <typename G>
- inline
- void
- edge_bkd_iterator<G>::next()
- {
- e_.update_id(e_.id() - 1);
- }
-
- template <typename G>
- inline
- unsigned
- edge_bkd_iterator<G>::index() const
- {
- return e_.id();
- }
-
- template <typename G>
- inline
- const util::edge<G>&
- edge_bkd_iterator<G>::subj_()
- {
- return e_;
- }
-
- } // End of namespace mln::internal
-
-} // End of namespace mln
-
-# endif // !MLN_INCLUDE_ONLY
-
-#endif // !MLN_UTIL_INTERNAL_GRAPH_EDGE_ITER_HH
-
diff --git a/milena/mln/util/internal/graph_edge_nbh_edge_iter.hh b/milena/mln/util/internal/graph_edge_nbh_edge_iter.hh
deleted file mode 100644
index 3ba8d0e..0000000
--- a/milena/mln/util/internal/graph_edge_nbh_edge_iter.hh
+++ /dev/null
@@ -1,335 +0,0 @@
-// Copyright (C) 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
-// of the GNU General Public License version 2 as published by the
-// Free Software Foundation.
-//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this library; see the file COPYING. If not, write to
-// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
-// Boston, MA 02111-1307, USA.
-//
-// As a special exception, you may use this file as part of a free
-// software library without restriction. Specifically, if other files
-// instantiate templates or use macros or inline functions from this
-// file, or you compile this file and link it with other files to
-// produce an executable, this file does not by itself cause the
-// resulting executable to be covered by the GNU General Public
-// License. This exception does not however invalidate any other
-// reasons why the executable file might be covered by the GNU General
-// Public License.
-
-#ifndef MLN_UTIL_INTERNAL_GRAPH_EDGE_NBH_EDGE_ITER_HH
-# define MLN_UTIL_INTERNAL_GRAPH_EDGE_NBH_EDGE_ITER_HH
-
-# include <mln/core/concept/proxy.hh>
-
-/// \file mln/util/internal/graph_edge_nbh_edge_iter.hh
-/// \brief Implementation for graph edge iterators centered to an edge.
-
-namespace mln
-{
-
- namespace internal
- {
-
- template <typename G>
- class edge_nbh_edge_fwd_iterator
- : public Proxy< edge_nbh_edge_fwd_iterator<G> >,
- public internal::proxy_impl< const util::edge<G>&, edge_nbh_edge_fwd_iterator<G> >
- {
- public:
- /// Construction and assignment.
- /// \{
- template <typename C>
- edge_nbh_edge_fwd_iterator(const C& c);
- /// \}
-
- /// Iterator interface.
- /// \{
- /// Test if the iterator is valid.
- bool is_valid() const;
- /// Invalidate the iterator.
- void invalidate();
-
- /// Start an iteration.
- void start();
-
- /// Go to the next value.
- void next();
-
- /// Return current index
- unsigned index() const;
- /// \}
-
- /// Proxy.
- /// \{
- /// Proxy subject
- const util::edge<G>& subj_();
- /// \}
-
- protected:
- void update_();
-
- template <typename C>
- void center_at(const C& c);
-
-
- const util::edge<G>* c_; //Center
- util::edge<G> e_;
- unsigned i_;
- };
-
- template <typename G>
- class edge_nbh_edge_bkd_iterator
- : public Proxy< edge_nbh_edge_bkd_iterator<G> >,
- public proxy_impl< const util::edge<G>&, edge_nbh_edge_bkd_iterator<G> >
- {
- public:
- /// Construction and assignment.
- /// \{
- template <typename C>
- edge_nbh_edge_bkd_iterator(const C& e);
- /// \}
-
- /// Iterator interface.
- /// \{
- /// Test if the iterator is valid.
- bool is_valid() const;
- /// Invalidate the iterator.
- void invalidate();
-
- /// Start an iteration.
- void start();
-
- /// Go to the next value.
- void next();
-
- /// Return current index
- unsigned index() const;
- /// \}
-
- /// Proxy.
- /// \{
- /// Proxy subject
- const util::edge<G>& subj_();
- /// \}
-
- protected:
- void update_();
-
- template <typename C>
- void center_at(const C& c);
-
- const util::edge<G>* c_; //Center
- util::edge<G> e_;
- unsigned i_;
- };
-
-
-# ifndef MLN_INCLUDE_ONLY
-
- template <typename G>
- template <typename C>
- inline
- edge_nbh_edge_fwd_iterator<G>::edge_nbh_edge_fwd_iterator(const C& c)
- : e_(c.g()), i_(0)
- {
- //FIXME: Check if typeof(e.g()) == G
- center_at(c);
- }
-
- template <typename G>
- inline
- bool
- edge_nbh_edge_fwd_iterator<G>::is_valid() const
- {
- return i_ < c_->nmax_nbh_edges();
- }
-
- template <typename G>
- inline
- void
- edge_nbh_edge_fwd_iterator<G>::invalidate()
- {
- i_ = e_.g().e_nmax();
- }
-
- template <typename G>
- inline
- void
- edge_nbh_edge_fwd_iterator<G>::start()
- {
- i_ = 0;
- if (is_valid())
- update_();
- }
-
- template <typename G>
- inline
- void
- edge_nbh_edge_fwd_iterator<G>::next()
- {
- ++i_;
- if (is_valid())
- update_();
- }
-
- template <typename G>
- inline
- unsigned
- edge_nbh_edge_fwd_iterator<G>::index() const
- {
- return i_;
- }
-
- template <typename G>
- inline
- const util::edge<G>&
- edge_nbh_edge_fwd_iterator<G>::subj_()
- {
- return e_;
- }
-
- template <typename G>
- inline
- void
- edge_nbh_edge_fwd_iterator<G>::update_()
- {
- mln_precondition(is_valid());
- mln_precondition(c_->is_valid());
-
- // We shall encounter vertices which are part of the
- // current edge.
- // We do not want them to be part of the edge neighbors.
- unsigned e_id = c_->ith_nbh_edge(i_);
- while (e_id == c_->id())
- e_id = c_->ith_nbh_edge(++i_);
-
- e_.update_id(e_id);
- }
-
- template <typename G>
- template <typename E>
- inline
- void
- edge_nbh_edge_fwd_iterator<G>::center_at(const E& c)
- {
- internal::get_adr(c_, c);
- mln_precondition(c_ != 0);
-
- invalidate();
- }
-
-
-
- /*---------------------------`
- | edge_nbh_edge_bkd_iterator |
- \---------------------------*/
-
- template <typename G>
- template <typename C>
- inline
- edge_nbh_edge_bkd_iterator<G>::edge_nbh_edge_bkd_iterator(const C& c)
- : e_(c.g()), i_(0)
- {
- //FIXME: Check if typeof(e.g()) == G
- center_at(c);
- }
-
- template <typename G>
- inline
- bool
- edge_nbh_edge_bkd_iterator<G>::is_valid() const
- {
- return i_ < c_->nmax_nbh_edges();
- }
-
- template <typename G>
- inline
- void
- edge_nbh_edge_bkd_iterator<G>::invalidate()
- {
- i_ = e_.g().e_nmax();
- }
-
- template <typename G>
- inline
- void
- edge_nbh_edge_bkd_iterator<G>::start()
- {
- i_ = c_->nmax_nbh_edges() - 1;
- if (is_valid())
- update_();
- }
-
- template <typename G>
- inline
- void
- edge_nbh_edge_bkd_iterator<G>::next()
- {
- --i_;
- if (is_valid())
- update_();
- }
-
- template <typename G>
- inline
- unsigned
- edge_nbh_edge_bkd_iterator<G>::index() const
- {
- return i_;
- }
-
- template <typename G>
- inline
- const util::edge<G>&
- edge_nbh_edge_bkd_iterator<G>::subj_()
- {
- return e_;
- }
-
- template <typename G>
- inline
- void
- edge_nbh_edge_bkd_iterator<G>::update_()
- {
- mln_precondition(is_valid());
- mln_precondition(c_->is_valid());
-
- // We shall encounter vertices which are part of the
- // current edge.
- // We do not want them to be part of the edge neighbors.
- unsigned e_id = c_->ith_nbh_edge(i_);
- while (e_id == c_->id())
- e_id = c_->ith_nbh_edge(--i_);
-
- e_.update_id(e_id);
- }
-
- template <typename G>
- template <typename E>
- inline
- void
- edge_nbh_edge_bkd_iterator<G>::center_at(const E& c)
- {
- internal::get_adr(c_, c);
- mln_precondition(c_ != 0);
-
- invalidate();
- }
-# endif // !MLN_INCLUDE_ONLY
-
- } // End of namespace mln::internal
-
-} // End of namespace mln
-
-
-#endif // !MLN_UTIL_INTERNAL_GRAPH_EDGE_NBH_EDGE_ITER_HH
-
diff --git a/milena/mln/util/internal/graph_iter.hh b/milena/mln/util/internal/graph_iter.hh
new file mode 100644
index 0000000..ab62582
--- /dev/null
+++ b/milena/mln/util/internal/graph_iter.hh
@@ -0,0 +1,298 @@
+// Copyright (C) 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
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef MLN_UTIL_INTERNAL_GRAPH_ITER_HH
+# define MLN_UTIL_INTERNAL_GRAPH_ITER_HH
+
+# include <mln/core/concept/iterator.hh>
+# include <mln/util/internal/graph_vertex.hh>
+# include <mln/util/internal/graph_edge.hh>
+# include <mln/util/internal/graph_iter_base.hh>
+
+/// \file mln/util/internal/graph_iter.hh
+/// \brief Implementation for graph iterators.
+
+namespace mln
+{
+
+ namespace internal
+ {
+
+ template<typename G>
+ class vertex_fwd_iterator
+ : public graph_iter_base<G, util::vertex<G>, vertex_fwd_iterator<G> >
+ {
+ typedef graph_iter_base<G, util::vertex<G>, vertex_fwd_iterator<G> > super_;
+
+ public:
+ /// Constructors.
+ /// \{
+ vertex_fwd_iterator();
+ vertex_fwd_iterator(const G& g);
+ /// \}
+
+ protected:
+ /// Returns the id of the first element.
+ /// Called in start();
+ unsigned start_id_() const;
+
+ /// Returns the next element id.
+ /// Called in next();
+ unsigned next_id_() const;
+
+ using super_::p_;
+ friend class graph_iter_base<G, util::vertex<G>, vertex_fwd_iterator<G> >;
+ };
+
+
+ template<typename G>
+ class vertex_bkd_iterator
+ : public graph_iter_base<G, util::vertex<G>, vertex_bkd_iterator<G> >
+ {
+ typedef graph_iter_base<G, util::vertex<G>, vertex_bkd_iterator<G> > super_;
+
+ public:
+ /// Constructors.
+ /// \{
+ vertex_bkd_iterator();
+ vertex_bkd_iterator(const G& g);
+ /// \}
+
+ protected:
+ /// Returns the id of the first element.
+ /// Called in start();
+ unsigned start_id_() const;
+
+ /// Returns the next element id.
+ /// Called in next();
+ unsigned next_id_() const;
+
+ using super_::p_;
+ friend class graph_iter_base<G, util::vertex<G>, vertex_bkd_iterator<G> >;
+ };
+
+ /// Forward edge iterator.
+ template <typename G>
+ class edge_fwd_iterator
+ : public graph_iter_base<G, util::edge<G>, edge_fwd_iterator<G> >
+ {
+ typedef graph_iter_base<G, util::edge<G>, edge_fwd_iterator<G> > super_;
+
+ public:
+ /// Constructors.
+ /// \{
+ edge_fwd_iterator();
+ edge_fwd_iterator(const G& g);
+ /// \}
+
+ protected:
+ /// Returns the id of the first element.
+ /// Called in start();
+ unsigned start_id_() const;
+
+ /// Returns the next element id.
+ /// Called in next();
+ unsigned next_id_() const;
+
+ using super_::p_;
+ friend class graph_iter_base<G, util::edge<G>, edge_fwd_iterator<G> >;
+ };
+
+ template <typename G>
+ class edge_bkd_iterator
+ : public graph_iter_base<G, util::edge<G>, edge_bkd_iterator<G> >
+ {
+ typedef graph_iter_base<G, util::edge<G>, edge_bkd_iterator<G> > super_;
+
+ public:
+ /// Constructors.
+ /// \{
+ edge_bkd_iterator();
+ edge_bkd_iterator(const G& g);
+ /// \}
+
+ protected:
+ /// Returns the id of the first element.
+ /// Called in start();
+ unsigned start_id_() const;
+
+ /// Returns the next element id.
+ /// Called in next();
+ unsigned next_id_() const;
+
+ using super_::p_;
+ friend class graph_iter_base<G, util::edge<G>, edge_bkd_iterator<G> >;
+ };
+
+# ifndef MLN_INCLUDE_ONLY
+
+ /*--------------------`
+ | vertex_fwd_iterator |
+ \--------------------*/
+
+ template <typename G>
+ inline
+ vertex_fwd_iterator<G>::vertex_fwd_iterator()
+ {
+ }
+
+ template <typename G>
+ inline
+ vertex_fwd_iterator<G>::vertex_fwd_iterator(const G& g)
+ : super_(g)
+ {
+ }
+
+ template <typename G>
+ inline
+ unsigned
+ vertex_fwd_iterator<G>::start_id_() const
+ {
+ return 0;
+ }
+
+ template <typename G>
+ inline
+ unsigned
+ vertex_fwd_iterator<G>::next_id_() const
+ {
+ return p_.id() + 1;
+ }
+
+
+
+ /*--------------------`
+ | vertex_bkd_iterator |
+ \--------------------*/
+
+ template <typename G>
+ inline
+ vertex_bkd_iterator<G>::vertex_bkd_iterator()
+ {
+ }
+
+ template <typename G>
+ inline
+ vertex_bkd_iterator<G>::vertex_bkd_iterator(const G& g)
+ : super_(g)
+ {
+ }
+
+ template <typename G>
+ inline
+ unsigned
+ vertex_bkd_iterator<G>::start_id_() const
+ {
+ return p_.g().v_nmax() - 1;
+ }
+
+ template <typename G>
+ inline
+ unsigned
+ vertex_bkd_iterator<G>::next_id_() const
+ {
+ return p_.id() - 1;
+ }
+
+
+
+ /*------------------`
+ | edge_fwd_iterator |
+ \------------------*/
+
+ template <typename G>
+ inline
+ edge_fwd_iterator<G>::edge_fwd_iterator()
+ {
+ }
+
+ template <typename G>
+ inline
+ edge_fwd_iterator<G>::edge_fwd_iterator(const G& g)
+ : super_(g)
+ {
+ }
+
+ template <typename G>
+ inline
+ unsigned
+ edge_fwd_iterator<G>::start_id_() const
+ {
+ return 0;
+ }
+
+ template <typename G>
+ inline
+ unsigned
+ edge_fwd_iterator<G>::next_id_() const
+ {
+ return p_.id() + 1;
+ }
+
+
+
+ /*------------------`
+ | edge_bkd_iterator |
+ \------------------*/
+
+ template <typename G>
+ inline
+ edge_bkd_iterator<G>::edge_bkd_iterator()
+ {
+ }
+
+ template <typename G>
+ inline
+ edge_bkd_iterator<G>::edge_bkd_iterator(const G& g)
+ : super_(g)
+ {
+ }
+
+ template <typename G>
+ inline
+ unsigned
+ edge_bkd_iterator<G>::start_id_() const
+ {
+ return p_.g().e_nmax() - 1;
+ }
+
+ template <typename G>
+ inline
+ unsigned
+ edge_bkd_iterator<G>::next_id_() const
+ {
+ return p_.id() - 1;
+ }
+
+# endif // !MLN_INCLUDE_ONLY
+
+ } // End of namespace mln::internal
+
+} // End of namespace mln
+
+#endif // !MLN_UTIL_INTERNAL_GRAPH_ITER_HH
+
diff --git a/milena/mln/util/internal/graph_iter_base.hh b/milena/mln/util/internal/graph_iter_base.hh
new file mode 100644
index 0000000..a901192
--- /dev/null
+++ b/milena/mln/util/internal/graph_iter_base.hh
@@ -0,0 +1,144 @@
+// Copyright (C) 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
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef MLN_UTIL_INTERNAL_GRAPH_ITER_BASE_HH
+# define MLN_UTIL_INTERNAL_GRAPH_ITER_BASE_HH
+
+# include <mln/core/concept/iterator.hh>
+# include <mln/core/concept/proxy.hh>
+# include <mln/util/internal/graph_edge.hh>
+
+/// \file mln/util/internal/graph_iter_base.hh
+/// \brief Base implementation for graph iterators.
+
+namespace mln
+{
+
+ namespace internal
+ {
+
+ template <typename G, typename P, typename E>
+ class graph_iter_base
+ : public Proxy< E >,
+ public internal::proxy_impl< const P&, E >
+ {
+ public:
+ /// Iterator interface
+ /// \{
+ /// Test if the iterator is valid.
+ bool is_valid() const;
+ /// Invalidate the iterator.
+ void invalidate();
+
+ /// Start an iteration.
+ void start();
+
+ /// Go to the next value.
+ void next();
+
+ /// Return current index
+ unsigned index() const;
+ /// \}
+
+ /// Proxy.
+ /// \{
+ /// Proxy subject
+ const P& subj_();
+ /// \}
+
+ protected:
+ graph_iter_base(const G& g);
+
+ P p_;
+ };
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename G, typename P, typename E>
+ inline
+ graph_iter_base<G, P, E>::graph_iter_base(const G& g)
+ : p_(P(g))
+ {
+ invalidate();
+ }
+
+ template <typename G, typename P, typename E>
+ inline
+ bool
+ graph_iter_base<G, P, E>::is_valid() const
+ {
+ return p_.is_valid();
+ }
+
+ template <typename G, typename P, typename E>
+ inline
+ void
+ graph_iter_base<G, P, E>::invalidate()
+ {
+ p_.invalidate();
+ }
+
+ template <typename G, typename P, typename E>
+ inline
+ void
+ graph_iter_base<G, P, E>::start()
+ {
+ p_.update_id(exact(this)->start_id_());
+ }
+
+ template <typename G, typename P, typename E>
+ inline
+ void
+ graph_iter_base<G, P, E>::next()
+ {
+ p_.update_id(exact(this)->next_id_());
+ }
+
+ template <typename G, typename P, typename E>
+ inline
+ unsigned
+ graph_iter_base<G, P, E>::index() const
+ {
+ return p_.id();
+ }
+
+ template <typename G, typename P, typename E>
+ inline
+ const P&
+ graph_iter_base<G, P, E>::subj_()
+ {
+ return p_;
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::internal
+
+} // end of namespace mln
+
+#endif // ! MLN_UTIL_INTERNAL_GRAPH_ITER_BASE_HH
+
diff --git a/milena/mln/util/internal/graph_nbh_iter.hh b/milena/mln/util/internal/graph_nbh_iter.hh
new file mode 100644
index 0000000..5edecef
--- /dev/null
+++ b/milena/mln/util/internal/graph_nbh_iter.hh
@@ -0,0 +1,636 @@
+// Copyright (C) 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
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef MLN_UTIL_INTERNAL_GRAPH_VERTEX_NBH_VERTEX_ITER_HH
+# define MLN_UTIL_INTERNAL_GRAPH_VERTEX_NBH_VERTEX_ITER_HH
+
+# include <mln/core/concept/proxy.hh>
+# include <mln/util/internal/graph_nbh_iter_base.hh>
+
+/// \file mln/util/internal/graph_vertex_nbh_vertex_iter.hh
+/// \brief Implementation for graph vertex iterators centered to a vertex.
+
+namespace mln
+{
+
+ namespace internal
+ {
+
+ /*-----------------------------`
+ | vertex_nbh_vertex_*_iterator |
+ \-----------------------------*/
+
+ template <typename G>
+ class vertex_nbh_vertex_fwd_iterator
+ : public nbh_iterator_base<G,
+ util::vertex<G>,
+ util::vertex<G>,
+ vertex_nbh_vertex_fwd_iterator<G> >
+ {
+ typedef util::vertex<G> V;
+ typedef vertex_nbh_vertex_fwd_iterator<G> self_;
+ typedef nbh_iterator_base<G, V, V, self_> super_;
+
+ public:
+ /// Construction and assignment.
+ /// \{
+ template <typename C>
+ vertex_nbh_vertex_fwd_iterator(const C& c);
+ /// \}
+
+ protected:
+ // Manipulation.
+ /// \{
+ /// Test if the iterator is valid.
+ bool is_valid_() const;
+ /// Invalidate the iterator.
+ void invalidate_();
+ /// \}
+
+ /// Start an iteration.
+ unsigned start_id_() const;
+
+ /// Go to the next value.
+ unsigned next_id_() const;
+
+ void update_();
+
+ friend class nbh_iterator_base<G, V, V, self_>;
+ };
+
+ template <typename G>
+ class vertex_nbh_vertex_bkd_iterator
+ : public nbh_iterator_base<G,
+ util::vertex<G>,
+ util::vertex<G>,
+ vertex_nbh_vertex_bkd_iterator<G> >
+ {
+ typedef util::vertex<G> V;
+ typedef vertex_nbh_vertex_bkd_iterator<G> self_;
+ typedef nbh_iterator_base<G, V, V, self_> super_;
+
+ public:
+ /// Construction and assignment.
+ /// \{
+ template <typename C>
+ vertex_nbh_vertex_bkd_iterator(const C& c);
+ /// \}
+
+ protected:
+ /// Manipulation.
+ /// \{
+ /// Test if the iterator is valid.
+ bool is_valid_() const;
+ /// Invalidate the iterator.
+ void invalidate_();
+ /// \}
+
+ /// Start an iteration.
+ unsigned start_id_() const;
+
+ /// Go to the next value.
+ unsigned next_id_() const;
+
+ void update_();
+
+ friend class nbh_iterator_base<G, V, V, self_>;
+ };
+
+
+ /*---------------------------`
+ | vertex_nbh_edge_*_iterator |
+ \---------------------------*/
+
+ template <typename G>
+ class vertex_nbh_edge_fwd_iterator
+ : public nbh_iterator_base<G,
+ util::vertex<G>,
+ util::edge<G>,
+ vertex_nbh_edge_fwd_iterator<G> >
+ {
+ typedef util::vertex<G> V;
+ typedef util::edge<G> E;
+ typedef vertex_nbh_edge_fwd_iterator<G> self_;
+ typedef nbh_iterator_base<G, V, E, self_> super_;
+
+ public:
+ /// Construction and assignment.
+ /// \{
+ template <typename C>
+ vertex_nbh_edge_fwd_iterator(const C& c);
+ /// \}
+
+ protected:
+ // Manipulation.
+ /// \{
+ /// Test if the iterator is valid.
+ bool is_valid_() const;
+ /// Invalidate the iterator.
+ void invalidate_();
+ /// \}
+
+ /// Start an iteration.
+ unsigned start_id_() const;
+
+ /// Go to the next value.
+ unsigned next_id_() const;
+
+ void update_();
+
+ friend class nbh_iterator_base<G, V, E, self_>;
+ };
+
+
+ template <typename G>
+ class vertex_nbh_edge_bkd_iterator
+ : public nbh_iterator_base<G,
+ util::vertex<G>,
+ util::edge<G>,
+ vertex_nbh_edge_bkd_iterator<G> >
+ {
+ typedef util::vertex<G> V;
+ typedef util::edge<G> E;
+ typedef vertex_nbh_edge_bkd_iterator<G> self_;
+ typedef nbh_iterator_base<G, V, E, self_> super_;
+
+ public:
+ /// Construction and assignment.
+ /// \{
+ template <typename C>
+ vertex_nbh_edge_bkd_iterator(const C& c);
+ /// \}
+
+ protected:
+ // Manipulation.
+ /// \{
+ /// Test if the iterator is valid.
+ bool is_valid_() const;
+ /// Invalidate the iterator.
+ void invalidate_();
+ /// \}
+
+ /// Start an iteration.
+ unsigned start_id_() const;
+
+ /// Go to the next value.
+ unsigned next_id_() const;
+
+ void update_();
+
+ friend class nbh_iterator_base<G, V, E, self_>;
+ };
+
+
+ /*---------------------------`
+ | edge_nbh_edge_*_iterator |
+ \---------------------------*/
+
+ template <typename G>
+ class edge_nbh_edge_fwd_iterator
+ : public nbh_iterator_base<G,
+ util::edge<G>,
+ util::edge<G>,
+ edge_nbh_edge_fwd_iterator<G> >
+ {
+ typedef util::edge<G> E;
+ typedef edge_nbh_edge_fwd_iterator<G> self_;
+ typedef nbh_iterator_base<G, E, E, self_> super_;
+
+ public:
+ /// Construction and assignment.
+ /// \{
+ template <typename C>
+ edge_nbh_edge_fwd_iterator(const C& c);
+ /// \}
+
+ protected:
+ // Manipulation.
+ /// \{
+ /// Test if the iterator is valid.
+ bool is_valid_() const;
+ /// Invalidate the iterator.
+ void invalidate_();
+ /// \}
+
+ /// Start an iteration.
+ unsigned start_id_() const;
+
+ /// Go to the next value.
+ unsigned next_id_() const;
+
+ void update_();
+
+ friend class nbh_iterator_base<G, E, E, self_>;
+ };
+
+
+ template <typename G>
+ class edge_nbh_edge_bkd_iterator
+ : public nbh_iterator_base<G,
+ util::edge<G>,
+ util::edge<G>,
+ edge_nbh_edge_bkd_iterator<G> >
+ {
+ typedef util::edge<G> E;
+ typedef edge_nbh_edge_bkd_iterator<G> self_;
+ typedef nbh_iterator_base<G, E, E, self_> super_;
+
+ public:
+ /// Construction and assignment.
+ /// \{
+ template <typename C>
+ edge_nbh_edge_bkd_iterator(const C& c);
+ /// \}
+
+ protected:
+ // Manipulation.
+ /// \{
+ /// Test if the iterator is valid.
+ bool is_valid_() const;
+ /// Invalidate the iterator.
+ void invalidate_();
+ /// \}
+
+ /// Start an iteration.
+ unsigned start_id_() const;
+
+ /// Go to the next value.
+ unsigned next_id_() const;
+
+ void update_();
+
+ friend class nbh_iterator_base<G, E, E, self_>;
+ };
+
+# ifndef MLN_INCLUDE_ONLY
+
+ /*-------------------------------`
+ | vertex_nbh_vertex_fwd_iterator |
+ \-------------------------------*/
+
+
+ template <typename G>
+ template <typename C>
+ inline
+ vertex_nbh_vertex_fwd_iterator<G>::vertex_nbh_vertex_fwd_iterator(const C& c)
+ : super_(c)
+ {
+ }
+
+ template <typename G>
+ inline
+ bool
+ vertex_nbh_vertex_fwd_iterator<G>::is_valid_() const
+ {
+ return this->i_ < this->c_->nmax_nbh_vertices();
+ }
+
+ template <typename G>
+ inline
+ void
+ vertex_nbh_vertex_fwd_iterator<G>::invalidate_()
+ {
+ this->i_ = this->p_.g().v_nmax();
+ }
+
+ template <typename G>
+ inline
+ unsigned
+ vertex_nbh_vertex_fwd_iterator<G>::start_id_() const
+ {
+ return 0;
+ }
+
+ template <typename G>
+ inline
+ unsigned
+ vertex_nbh_vertex_fwd_iterator<G>::next_id_() const
+ {
+ return this->i_ + 1;
+ }
+
+ template <typename G>
+ inline
+ void
+ vertex_nbh_vertex_fwd_iterator<G>::update_()
+ {
+ this->p_.update_id(this->c_->ith_nbh_vertex(this->i_));
+ }
+
+ /*-------------------------------`
+ | vertex_nbh_vertex_bkd_iterator |
+ \-------------------------------*/
+
+
+ template <typename G>
+ template <typename C>
+ inline
+ vertex_nbh_vertex_bkd_iterator<G>::vertex_nbh_vertex_bkd_iterator(const C& c)
+ : super_(c)
+ {
+ }
+
+ template <typename G>
+ inline
+ bool
+ vertex_nbh_vertex_bkd_iterator<G>::is_valid_() const
+ {
+ return this->i_ < this->c_->nmax_nbh_vertices();
+ }
+
+ template <typename G>
+ inline
+ void
+ vertex_nbh_vertex_bkd_iterator<G>::invalidate_()
+ {
+ this->i_ = this->p_.g().v_nmax();
+ }
+
+ template <typename G>
+ inline
+ unsigned
+ vertex_nbh_vertex_bkd_iterator<G>::start_id_() const
+ {
+ return this->c_->nmax_nbh_vertices() - 1;
+ }
+
+ template <typename G>
+ inline
+ unsigned
+ vertex_nbh_vertex_bkd_iterator<G>::next_id_() const
+ {
+ return this->i_ - 1;
+ }
+
+ template <typename G>
+ inline
+ void
+ vertex_nbh_vertex_bkd_iterator<G>::update_()
+ {
+ this->p_.update_id(this->c_->ith_nbh_vertex(this->i_));
+ }
+
+
+ /*-----------------------------`
+ | vertex_nbh_edge_fwd_iterator |
+ \-----------------------------*/
+
+ template <typename G>
+ template <typename C>
+ inline
+ vertex_nbh_edge_fwd_iterator<G>::vertex_nbh_edge_fwd_iterator(const C& c)
+ : super_(c)
+ {
+ }
+
+ template <typename G>
+ inline
+ bool
+ vertex_nbh_edge_fwd_iterator<G>::is_valid_() const
+ {
+ return this->i_ < this->c_->nmax_nbh_edges();
+ }
+
+ template <typename G>
+ inline
+ void
+ vertex_nbh_edge_fwd_iterator<G>::invalidate_()
+ {
+ this->i_ = this->p_.g().e_nmax();
+ }
+
+ template <typename G>
+ inline
+ unsigned
+ vertex_nbh_edge_fwd_iterator<G>::start_id_() const
+ {
+ return 0;
+ }
+
+ template <typename G>
+ inline
+ unsigned
+ vertex_nbh_edge_fwd_iterator<G>::next_id_() const
+ {
+ return this->i_ + 1;
+ }
+
+ template <typename G>
+ inline
+ void
+ vertex_nbh_edge_fwd_iterator<G>::update_()
+ {
+ this->p_.update_id(this->c_->ith_nbh_edge(this->i_));
+ }
+
+ /*-----------------------------`
+ | vertex_nbh_edge_bkd_iterator |
+ \-----------------------------*/
+
+ template <typename G>
+ template <typename C>
+ inline
+ vertex_nbh_edge_bkd_iterator<G>::vertex_nbh_edge_bkd_iterator(const C& c)
+ : super_(c)
+ {
+ }
+
+ template <typename G>
+ inline
+ bool
+ vertex_nbh_edge_bkd_iterator<G>::is_valid_() const
+ {
+ return this->i_ < this->c_->nmax_nbh_edges();
+ }
+
+ template <typename G>
+ inline
+ void
+ vertex_nbh_edge_bkd_iterator<G>::invalidate_()
+ {
+ this->i_ = this->p_.g().e_nmax();
+ }
+
+ template <typename G>
+ inline
+ unsigned
+ vertex_nbh_edge_bkd_iterator<G>::start_id_() const
+ {
+ return this->c_->nmax_nbh_edges() - 1;
+ }
+
+ template <typename G>
+ inline
+ unsigned
+ vertex_nbh_edge_bkd_iterator<G>::next_id_() const
+ {
+ return this->i_ - 1;
+ }
+
+ template <typename G>
+ inline
+ void
+ vertex_nbh_edge_bkd_iterator<G>::update_()
+ {
+ this->p_.update_id(this->c_->ith_nbh_edge(this->i_));
+ }
+
+
+
+ /*-----------------------------`
+ | edge_nbh_edge_fwd_iterator |
+ \-----------------------------*/
+
+ template <typename G>
+ template <typename C>
+ inline
+ edge_nbh_edge_fwd_iterator<G>::edge_nbh_edge_fwd_iterator(const C& c)
+ : super_(c)
+ {
+ }
+
+ template <typename G>
+ inline
+ bool
+ edge_nbh_edge_fwd_iterator<G>::is_valid_() const
+ {
+ return this->i_ < this->c_->nmax_nbh_edges();
+ }
+
+ template <typename G>
+ inline
+ void
+ edge_nbh_edge_fwd_iterator<G>::invalidate_()
+ {
+ this->i_ = this->p_.g().e_nmax();
+ }
+
+ template <typename G>
+ inline
+ unsigned
+ edge_nbh_edge_fwd_iterator<G>::start_id_() const
+ {
+ return 0;
+ }
+
+ template <typename G>
+ inline
+ unsigned
+ edge_nbh_edge_fwd_iterator<G>::next_id_() const
+ {
+ return this->i_ + 1;
+ }
+
+ template <typename G>
+ inline
+ void
+ edge_nbh_edge_fwd_iterator<G>::update_()
+ {
+ // We shall encounter vertices which are part of the
+ // current edge.
+ // We do not want them to be part of the edge neighbors.
+ unsigned e_id = this->c_->ith_nbh_edge(this->i_);
+ while (e_id == this->c_->id())
+ {
+ this->i_ = next_id_();
+ e_id = this->c_->ith_nbh_edge(this->i_);
+ }
+
+ this->p_.update_id(e_id);
+ }
+
+ /*-----------------------------`
+ | edge_nbh_edge_bkd_iterator |
+ \-----------------------------*/
+
+ template <typename G>
+ template <typename C>
+ inline
+ edge_nbh_edge_bkd_iterator<G>::edge_nbh_edge_bkd_iterator(const C& c)
+ : super_(c)
+ {
+ }
+
+ template <typename G>
+ inline
+ bool
+ edge_nbh_edge_bkd_iterator<G>::is_valid_() const
+ {
+ return this->i_ < this->c_->nmax_nbh_edges();
+ }
+
+ template <typename G>
+ inline
+ void
+ edge_nbh_edge_bkd_iterator<G>::invalidate_()
+ {
+ this->i_ = this->p_.g().e_nmax();
+ }
+
+ template <typename G>
+ inline
+ unsigned
+ edge_nbh_edge_bkd_iterator<G>::start_id_() const
+ {
+ return this->c_->nmax_nbh_edges() - 1;
+ }
+
+ template <typename G>
+ inline
+ unsigned
+ edge_nbh_edge_bkd_iterator<G>::next_id_() const
+ {
+ return this->i_ - 1;
+ }
+
+ template <typename G>
+ inline
+ void
+ edge_nbh_edge_bkd_iterator<G>::update_()
+ {
+ // We shall encounter vertices which are part of the
+ // current edge.
+ // We do not want them to be part of the edge neighbors.
+ unsigned e_id = this->c_->ith_nbh_edge(this->i_);
+ while (e_id == this->c_->id())
+ {
+ this->i_ = next_id_();
+ e_id = this->c_->ith_nbh_edge(this->i_);
+ }
+
+ this->p_.update_id(e_id);
+ }
+
+# endif // !MLN_INCLUDE_ONLY
+
+ } // End of namespace mln::internal
+
+} // End of namespace mln
+
+
+#endif // !MLN_UTIL_INTERNAL_GRAPH_VERTEX_NBH_VERTEX_ITER_HH
+
diff --git a/milena/mln/util/internal/graph_nbh_iter_base.hh b/milena/mln/util/internal/graph_nbh_iter_base.hh
new file mode 100644
index 0000000..8cfcdd6
--- /dev/null
+++ b/milena/mln/util/internal/graph_nbh_iter_base.hh
@@ -0,0 +1,175 @@
+// Copyright (C) 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
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef MLN_UTIL_INTERNAL_GRAPH_NBH_ITER_BASE_HH
+# define MLN_UTIL_INTERNAL_GRAPH_NBH_ITER_BASE_HH
+
+# include <mln/core/concept/proxy.hh>
+
+/// \file mln/util/internal/graph_nbh_iter_base.hh
+/// \brief Base implementation for graph edge and vertex neighborhood iterator.
+
+namespace mln
+{
+
+ namespace internal
+ {
+
+ template <typename G, typename C, typename P, typename E>
+ class nbh_iterator_base
+ : public Proxy< E >,
+ public internal::proxy_impl< const P&, E >
+ {
+ public:
+
+ /// Iterator interface.
+ /// \{
+ /// Test if the iterator is valid.
+ bool is_valid() const;
+ /// Invalidate the iterator.
+ void invalidate();
+
+ /// Start an iteration.
+ void start();
+
+ /// Go to the next value.
+ void next();
+
+ /// Return current index
+ unsigned index() const;
+ /// \}
+
+ /// Proxy.
+ /// \{
+ /// Proxy subject
+ const P& subj_();
+ /// \}
+
+ protected:
+ /// Construction and assignment.
+ /// \{
+ template <typename C2>
+ nbh_iterator_base(const C2& c);
+ /// \}
+
+ template <typename C2>
+ void center_at(const C2& c);
+
+ const C* c_; // Center
+ P p_;
+ unsigned i_;
+ };
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename G, typename C, typename P, typename E>
+ template <typename C2>
+ inline
+ nbh_iterator_base<G, C, P, E>::nbh_iterator_base(const C2& c)
+ : p_(c.g()), i_(0)
+ {
+ //FIXME: Check if typeof(e.g()) == G
+ center_at(c);
+ }
+
+ template <typename G, typename C, typename P, typename E>
+ inline
+ bool
+ nbh_iterator_base<G, C, P, E>::is_valid() const
+ {
+ return exact(this)->is_valid_();
+ }
+
+ template <typename G, typename C, typename P, typename E>
+ inline
+ void
+ nbh_iterator_base<G, C, P, E>::invalidate()
+ {
+ exact(this)->invalidate_();
+ }
+
+ template <typename G, typename C, typename P, typename E>
+ inline
+ void
+ nbh_iterator_base<G, C, P, E>::start()
+ {
+ i_ = exact(this)->start_id_();
+ if (is_valid())
+ exact(this)->update_();
+ }
+
+ template <typename G, typename C, typename P, typename E>
+ inline
+ void
+ nbh_iterator_base<G, C, P, E>::next()
+ {
+ mln_precondition(is_valid());
+ mln_precondition(c_->is_valid());
+
+ i_ = exact(this)->next_id_();
+ if (is_valid())
+ exact(this)->update_();
+ }
+
+ template <typename G, typename C, typename P, typename E>
+ inline
+ unsigned
+ nbh_iterator_base<G, C, P, E>::index() const
+ {
+ return i_;
+ }
+
+ template <typename G, typename C, typename P, typename E>
+ inline
+ const P&
+ nbh_iterator_base<G, C, P, E>::subj_()
+ {
+ return p_;
+ }
+
+ template <typename G, typename C, typename P, typename E>
+ template <typename C2>
+ inline
+ void
+ nbh_iterator_base<G, C, P, E>::center_at(const C2& c)
+ {
+ internal::get_adr(c_, c);
+ mln_precondition(c_ != 0);
+
+ invalidate();
+ }
+
+# endif // !MLN_INCLUDE_ONLY
+
+ } // End of namespace mln::internal
+
+} // End of namespace mln
+
+
+#endif // !MLN_UTIL_INTERNAL_GRAPH_NBH_ITER_BASE_HH
+
+
diff --git a/milena/mln/util/internal/graph_vertex_iter.hh b/milena/mln/util/internal/graph_vertex_iter.hh
deleted file mode 100644
index d77611f..0000000
--- a/milena/mln/util/internal/graph_vertex_iter.hh
+++ /dev/null
@@ -1,286 +0,0 @@
-// Copyright (C) 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
-// of the GNU General Public License version 2 as published by the
-// Free Software Foundation.
-//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this library; see the file COPYING. If not, write to
-// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
-// Boston, MA 02111-1307, USA.
-//
-// As a special exception, you may use this file as part of a free
-// software library without restriction. Specifically, if other files
-// instantiate templates or use macros or inline functions from this
-// file, or you compile this file and link it with other files to
-// produce an executable, this file does not by itself cause the
-// resulting executable to be covered by the GNU General Public
-// License. This exception does not however invalidate any other
-// reasons why the executable file might be covered by the GNU General
-// Public License.
-
-#ifndef MLN_UTIL_INTERNAL_GRAPH_VERTEX_ITER_HH
-# define MLN_UTIL_INTERNAL_GRAPH_VERTEX_ITER_HH
-
-# include <mln/metal/const.hh>
-# include <mln/core/concept/iterator.hh>
-# include <mln/core/concept/proxy.hh>
-# include <mln/util/internal/graph_base.hh>
-
-/// \file mln/util/internal/graph_vertex_iter.hh
-/// \brief Implementation for graph vertex iterators.
-
-namespace mln
-{
-
- namespace internal
- {
-
- template<typename G>
- class vertex_fwd_iterator
- : public Proxy< vertex_fwd_iterator<G> >,
- public proxy_impl< const util::vertex<G>&, vertex_fwd_iterator<G> >
- {
- public:
- /// Constructors.
- /// \{
- vertex_fwd_iterator();
- vertex_fwd_iterator(const G& g);
- /// \}
-
- /// Iterator interface.
- /// \{
- /// Test if the iterator is valid.
- bool is_valid() const;
- /// Invalidate the iterator.
- void invalidate();
-
- /// Start an iteration.
- void start();
-
- /// Go to the next value.
- void next();
-
- /// Return current index
- unsigned index() const;
- /// \}
-
- void update_graph(const G& g);
-
- /// Proxy.
- /// \{
- /// Proxy subject
- const util::vertex<G>& subj_();
- /// \}
-
- protected:
- util::vertex<G> v_;
- };
-
- template<typename G>
- class vertex_bkd_iterator
- : public Proxy< vertex_bkd_iterator<G> >,
- public proxy_impl< const util::vertex<G>&, vertex_fwd_iterator<G> >
- {
- public:
- /// Constructors.
- /// \{
- vertex_bkd_iterator();
- vertex_bkd_iterator(const G& g);
- /// \}
-
- /// Iterator interface.
- /// \{
- /// Test if the iterator is valid.
- bool is_valid() const;
- /// Invalidate the iterator.
- void invalidate();
-
- /// Start an iteration.
- void start();
-
- /// Go to the next value.
- void next();
-
- void update_graph(const G& g);
-
- /// Return current index
- unsigned index() const;
- /// \}
-
- /// Proxy.
- /// \{
- /// Proxy subject
- const util::vertex<G>& subj_();
- /// \}
-
- protected:
- util::vertex<G> v_;
- };
-
-
-# ifndef MLN_INCLUDE_ONLY
-
- /*--------------------`
- | vertex_fwd_iterator |
- \--------------------*/
-
- template<typename G>
- inline
- vertex_fwd_iterator<G>::vertex_fwd_iterator()
- {
- }
-
- template<typename G>
- inline
- vertex_fwd_iterator<G>::vertex_fwd_iterator(const G& g)
- {
- update_graph(g);
- invalidate();
- }
-
- template<typename G>
- inline
- bool
- vertex_fwd_iterator<G>::is_valid() const
- {
- return v_.is_valid();
- }
-
- template<typename G>
- inline
- void
- vertex_fwd_iterator<G>::invalidate()
- {
- v_.update_id(v_.g().v_nmax());
- }
-
- template<typename G>
- inline
- void
- vertex_fwd_iterator<G>::start()
- {
- v_.update_id(0);
- }
-
- template<typename G>
- inline
- void
- vertex_fwd_iterator<G>::next()
- {
- v_.update_id(v_.id() + 1);
- }
-
- template<typename G>
- inline
- void
- vertex_fwd_iterator<G>::update_graph(const G& g)
- {
- v_ = util::vertex<G>(g);
- }
-
- template<typename G>
- inline
- unsigned
- vertex_fwd_iterator<G>::index() const
- {
- return v_.id();
- }
-
- template<typename G>
- inline
- const util::vertex<G>&
- vertex_fwd_iterator<G>::subj_()
- {
- return v_;
- }
-
-
- /*--------------------`
- | vertex_bkd_iterator |
- \--------------------*/
-
- template<typename G>
- inline
- vertex_bkd_iterator<G>::vertex_bkd_iterator()
- {
- }
-
- template<typename G>
- inline
- vertex_bkd_iterator<G>::vertex_bkd_iterator(const G& g)
- {
- update_graph(g);
- invalidate();
- }
-
- template<typename G>
- inline
- bool
- vertex_bkd_iterator<G>::is_valid() const
- {
- return v_.is_valid();
- }
-
- template<typename G>
- inline
- void
- vertex_bkd_iterator<G>::invalidate()
- {
- v_.update_id(v_.g().v_nmax());
- }
-
- template<typename G>
- inline
- void
- vertex_bkd_iterator<G>::start()
- {
- v_.update_id(v_.g().v_nmax() - 1);
- }
-
- template<typename G>
- inline
- void
- vertex_bkd_iterator<G>::next()
- {
- v_.update_id(v_.id() - 1);
- }
-
- template<typename G>
- inline
- void
- vertex_bkd_iterator<G>::update_graph(const G& g)
- {
- v_ = util::vertex<G>(g);
- }
-
- template<typename G>
- inline
- unsigned
- vertex_bkd_iterator<G>::index() const
- {
- return v_.id();
- }
-
- template<typename G>
- inline
- const util::vertex<G>&
- vertex_bkd_iterator<G>::subj_()
- {
- return v_;
- }
-# endif // !MLN_INCLUDE_ONLY
-
- } // End of namespace mln::internal
-
-} // End of namespace mln
-
-
-#endif // !MLN_UTIL_INTERNAL_GRAPH_VERTEX_ITER_HH
-
diff --git a/milena/mln/util/internal/graph_vertex_nbh_edge_iter.hh b/milena/mln/util/internal/graph_vertex_nbh_edge_iter.hh
deleted file mode 100644
index 634dc07..0000000
--- a/milena/mln/util/internal/graph_vertex_nbh_edge_iter.hh
+++ /dev/null
@@ -1,323 +0,0 @@
-// Copyright (C) 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
-// of the GNU General Public License version 2 as published by the
-// Free Software Foundation.
-//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this library; see the file COPYING. If not, write to
-// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
-// Boston, MA 02111-1307, USA.
-//
-// As a special exception, you may use this file as part of a free
-// software library without restriction. Specifically, if other files
-// instantiate templates or use macros or inline functions from this
-// file, or you compile this file and link it with other files to
-// produce an executable, this file does not by itself cause the
-// resulting executable to be covered by the GNU General Public
-// License. This exception does not however invalidate any other
-// reasons why the executable file might be covered by the GNU General
-// Public License.
-
-#ifndef MLN_UTIL_INTERNAL_GRAPH_VERTEX_NBH_EDGE_ITER_HH
-# define MLN_UTIL_INTERNAL_GRAPH_VERTEX_NBH_EDGE_ITER_HH
-
-# include <mln/core/concept/proxy.hh>
-
-/// \file mln/util/internal/graph_vertex_nbh_edge_iter.hh
-/// \brief Implementation for graph edge iterators centered to a vertex.
-
-namespace mln
-{
-
- namespace internal
- {
-
- template <typename G>
- class vertex_nbh_edge_fwd_iterator
- : public Proxy< vertex_nbh_edge_fwd_iterator<G> >,
- public internal::proxy_impl< const util::edge<G>&, vertex_nbh_edge_fwd_iterator<G> >
- {
- public:
- /// Construction and assignment.
- /// \{
- template <typename C>
- vertex_nbh_edge_fwd_iterator(const C& c);
- /// \}
-
- /// Iterator interface.
- /// \{
- /// Test if the iterator is valid.
- bool is_valid() const;
- /// Invalidate the iterator.
- void invalidate();
-
- /// Start an iteration.
- void start();
-
- /// Go to the next value.
- void next();
-
- /// Return current index
- unsigned index() const;
- /// \}
-
- /// Proxy.
- /// \{
- /// Proxy subject
- const util::edge<G>& subj_();
- /// \}
-
- protected:
- void update_();
-
- template <typename C>
- void center_at(const C& c);
-
- const util::vertex<G>* c_; // Center
- util::edge<G> e_;
- unsigned i_;
- };
-
- template <typename G>
- class vertex_nbh_edge_bkd_iterator
- : public Proxy< vertex_nbh_edge_bkd_iterator<G> >,
- public proxy_impl< const util::edge<G>&, vertex_nbh_edge_bkd_iterator<G> >
- {
- public:
- /// Constructors.
- /// \{
- template <typename C>
- vertex_nbh_edge_bkd_iterator(const C& c);
- /// \}
-
- /// Iterator interface.
- /// \{
- /// Test if the iterator is valid.
- bool is_valid() const;
- /// Invalidate the iterator.
- void invalidate();
-
- /// Start an iteration.
- void start();
-
- /// Go to the next value.
- void next();
-
- /// Return current index
- unsigned index() const;
- /// \}
-
- /// Proxy.
- /// \{
- /// Proxy subject
- const util::edge<G>& subj_();
- /// \}
-
- protected:
- void update_();
-
- template <typename C>
- void center_at(const C& c);
-
- const util::vertex<G>* c_; //Center
- util::edge<G> e_;
- unsigned i_;
- };
-
-
-# ifndef MLN_INCLUDE_ONLY
-
- template <typename G>
- template <typename C>
- inline
- vertex_nbh_edge_fwd_iterator<G>::vertex_nbh_edge_fwd_iterator(const C& c)
- : e_(c.g()), i_(0)
- {
- //FIXME: Check if typeof(v.g()) == G
- center_at(c);
- }
-
- template <typename G>
- inline
- bool
- vertex_nbh_edge_fwd_iterator<G>::is_valid() const
- {
- return i_ < c_->nmax_nbh_edges();
- }
-
- template <typename G>
- inline
- void
- vertex_nbh_edge_fwd_iterator<G>::invalidate()
- {
- i_ = e_.g().e_nmax();
- }
-
- template <typename G>
- inline
- void
- vertex_nbh_edge_fwd_iterator<G>::start()
- {
- i_ = 0;
- if (is_valid())
- update_();
- }
-
- template <typename G>
- inline
- void
- vertex_nbh_edge_fwd_iterator<G>::next()
- {
- ++i_;
- if (is_valid())
- update_();
- }
-
- template <typename G>
- inline
- unsigned
- vertex_nbh_edge_fwd_iterator<G>::index() const
- {
- return i_;
- }
-
- template <typename G>
- inline
- const util::edge<G>&
- vertex_nbh_edge_fwd_iterator<G>::subj_()
- {
- return e_;
- }
-
- template <typename G>
- inline
- void
- vertex_nbh_edge_fwd_iterator<G>::update_()
- {
- mln_precondition(is_valid());
- mln_precondition(c_->is_valid());
- e_.update_id(c_->ith_nbh_edge(i_));
- }
-
- template <typename G>
- template <typename C>
- inline
- void
- vertex_nbh_edge_fwd_iterator<G>::center_at(const C& c)
- {
- internal::get_adr(c_, c);
- mln_precondition(c_ != 0);
-
- invalidate();
- }
-
-
-
-
- /*-----------------------------`
- | vertex_nbh_edge_bkd_iterator |
- \-----------------------------*/
-
-
- template <typename G>
- template <typename C>
- inline
- vertex_nbh_edge_bkd_iterator<G>::vertex_nbh_edge_bkd_iterator(const C& c)
- : e_(c.g()), i_(0)
- {
- //FIXME: Check if typeof(v.g()) == G
- center_at(c);
- }
-
- template <typename G>
- inline
- bool
- vertex_nbh_edge_bkd_iterator<G>::is_valid() const
- {
- return i_ < c_->nmax_nbh_edges();
- }
-
- template <typename G>
- inline
- void
- vertex_nbh_edge_bkd_iterator<G>::invalidate()
- {
- e_.update_id(e_.g().e_nmax());
- }
-
- template <typename G>
- inline
- void
- vertex_nbh_edge_bkd_iterator<G>::start()
- {
- i_ = c_->nmax_nbh_edges() - 1;
- if (is_valid())
- update_();
- }
-
- template <typename G>
- inline
- void
- vertex_nbh_edge_bkd_iterator<G>::next()
- {
- --i_;
- if (is_valid())
- update_();
- }
-
- template <typename G>
- inline
- unsigned
- vertex_nbh_edge_bkd_iterator<G>::index() const
- {
- return i_;
- }
-
- template <typename G>
- inline
- const util::edge<G>&
- vertex_nbh_edge_bkd_iterator<G>::subj_()
- {
- return e_;
- }
-
- template <typename G>
- inline
- void
- vertex_nbh_edge_bkd_iterator<G>::update_()
- {
- mln_precondition(is_valid());
- mln_precondition(c_->is_valid());
- e_.update_id(c_->ith_nbh_edge(i_));
- }
-
- template <typename G>
- template <typename C>
- inline
- void
- vertex_nbh_edge_bkd_iterator<G>::center_at(const C& c)
- {
- internal::get_adr(c_, c);
- mln_precondition(c_ != 0);
-
- invalidate();
- }
-
-
-
-# endif // !MLN_INCLUDE_ONLY
-
- } // End of namespace mln::internal
-
-} // End of namespace mln
-
-
-#endif // !MLN_UTIL_INTERNAL_GRAPH_NBH_EDGE_ITER_HH
-
diff --git a/milena/mln/util/internal/graph_vertex_nbh_vertex_iter.hh b/milena/mln/util/internal/graph_vertex_nbh_vertex_iter.hh
deleted file mode 100644
index 0dc87b5..0000000
--- a/milena/mln/util/internal/graph_vertex_nbh_vertex_iter.hh
+++ /dev/null
@@ -1,320 +0,0 @@
-// Copyright (C) 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
-// of the GNU General Public License version 2 as published by the
-// Free Software Foundation.
-//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this library; see the file COPYING. If not, write to
-// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
-// Boston, MA 02111-1307, USA.
-//
-// As a special exception, you may use this file as part of a free
-// software library without restriction. Specifically, if other files
-// instantiate templates or use macros or inline functions from this
-// file, or you compile this file and link it with other files to
-// produce an executable, this file does not by itself cause the
-// resulting executable to be covered by the GNU General Public
-// License. This exception does not however invalidate any other
-// reasons why the executable file might be covered by the GNU General
-// Public License.
-
-#ifndef MLN_UTIL_INTERNAL_GRAPH_VERTEX_NBH_VERTEX_ITER_HH
-# define MLN_UTIL_INTERNAL_GRAPH_VERTEX_NBH_VERTEX_ITER_HH
-
-# include <mln/core/concept/proxy.hh>
-
-/// \file mln/util/internal/graph_vertex_nbh_vertex_iter.hh
-/// \brief Implementation for graph vertex iterators centered to a vertex.
-
-namespace mln
-{
-
- namespace internal
- {
-
- template <typename G>
- class vertex_nbh_vertex_fwd_iterator
- : public Proxy< vertex_nbh_vertex_fwd_iterator<G> >,
- public internal::proxy_impl< const util::vertex<G>&, vertex_nbh_vertex_fwd_iterator<G> >
- {
- public:
- /// Construction and assignment.
- /// \{
- template <typename C>
- vertex_nbh_vertex_fwd_iterator(const C& c);
- /// \}
-
- /// Manipulation.
- /// \{
- /// Test if the iterator is valid.
- bool is_valid() const;
- /// Invalidate the iterator.
- void invalidate();
- /// \}
-
- /// Start an iteration.
- void start();
-
- /// Go to the next value.
- void next();
-
- /// Return current index
- unsigned index() const;
-
- /// Proxy.
- /// \{
- /// Proxy subject
- const util::vertex<G>& subj_();
- /// \}
-
- protected:
- void update_();
-
- template <typename C>
- void center_at(const C& c);
-
- const util::vertex<G>* c_;
- util::vertex<G> v_;
- unsigned i_;
- };
-
- template <typename G>
- class vertex_nbh_vertex_bkd_iterator
- : public Proxy< vertex_nbh_vertex_bkd_iterator<G> >,
- public proxy_impl< const util::vertex<G>&, vertex_nbh_vertex_fwd_iterator<G> >
- {
- public:
- /// Constructors.
- /// \{
- template <typename C>
- vertex_nbh_vertex_bkd_iterator(const C& v);
- /// \}
-
- /// Manipulation.
- /// \{
- /// Test if the iterator is valid.
- bool is_valid() const;
- /// Invalidate the iterator.
- void invalidate();
-
- /// Start an iteration.
- void start();
-
- /// Go to the next value.
- void next();
-
- /// Return current index
- unsigned index() const;
- /// \}
-
- /// Proxy.
- /// \{
- /// Proxy subject
- const util::vertex<G>& subj_();
- /// \}
-
- protected:
- void update_();
-
- template <typename C>
- void center_at(const C& c);
-
- const util::vertex<G>* c_; //Center
- util::vertex<G> v_;
- unsigned i_;
- };
-
-
-# ifndef MLN_INCLUDE_ONLY
-
-
- template <typename G>
- template <typename C>
- inline
- vertex_nbh_vertex_fwd_iterator<G>::vertex_nbh_vertex_fwd_iterator(const C& c)
- : v_(c.g()), i_(0)
- {
- //FIXME: Check if typeof(v.g()) == G
- center_at(c);
- }
-
- template <typename G>
- inline
- bool
- vertex_nbh_vertex_fwd_iterator<G>::is_valid() const
- {
- return i_ < c_->nmax_nbh_vertices();
- }
-
- template <typename G>
- inline
- void
- vertex_nbh_vertex_fwd_iterator<G>::invalidate()
- {
- i_ = v_.g().v_nmax();
- }
-
- template <typename G>
- inline
- void
- vertex_nbh_vertex_fwd_iterator<G>::start()
- {
- i_ = 0;
- if (is_valid())
- update_();
- }
-
- template <typename G>
- inline
- void
- vertex_nbh_vertex_fwd_iterator<G>::next()
- {
- ++i_;
- if (is_valid())
- update_();
- }
-
- template <typename G>
- inline
- unsigned
- vertex_nbh_vertex_fwd_iterator<G>::index() const
- {
- return i_;
- }
-
- template <typename G>
- inline
- const util::vertex<G>&
- vertex_nbh_vertex_fwd_iterator<G>::subj_()
- {
- return v_;
- }
-
- template <typename G>
- inline
- void
- vertex_nbh_vertex_fwd_iterator<G>::update_()
- {
- mln_precondition(is_valid());
- mln_precondition(c_->is_valid());
- v_.update_id(c_->ith_nbh_vertex(i_));
- }
-
- template <typename G>
- template <typename C>
- inline
- void
- vertex_nbh_vertex_fwd_iterator<G>::center_at(const C& c)
- {
- internal::get_adr(c_, c);
- mln_precondition(c_ != 0);
-
- invalidate();
- }
-
-
- /*-------------------------------`
- | vertex_nbh_vertex_bkd_iterator |
- \-------------------------------*/
-
-
- template <typename G>
- template <typename C>
- inline
- vertex_nbh_vertex_bkd_iterator<G>::vertex_nbh_vertex_bkd_iterator(const C& c)
- : v_(c.g()), i_(0)
- {
- //FIXME: Check if typeof(v.g()) == G
- center_at(c);
- }
-
- template <typename G>
- inline
- bool
- vertex_nbh_vertex_bkd_iterator<G>::is_valid() const
- {
- return i_ < c_->nmax_nbh_vertices();
- }
-
- template <typename G>
- inline
- void
- vertex_nbh_vertex_bkd_iterator<G>::invalidate()
- {
- v_.update_id(v_.g().e_nmax());
- }
-
- template <typename G>
- inline
- void
- vertex_nbh_vertex_bkd_iterator<G>::start()
- {
- i_ = c_->nmax_nbh_edges() - 1;
- if (is_valid())
- update_();
- }
-
- template <typename G>
- inline
- void
- vertex_nbh_vertex_bkd_iterator<G>::next()
- {
- --i_;
- if (is_valid())
- update_();
- }
-
- template <typename G>
- inline
- unsigned
- vertex_nbh_vertex_bkd_iterator<G>::index() const
- {
- return i_;
- }
-
- template <typename G>
- inline
- const util::vertex<G>&
- vertex_nbh_vertex_bkd_iterator<G>::subj_()
- {
- return v_;
- }
-
- template <typename G>
- inline
- void
- vertex_nbh_vertex_bkd_iterator<G>::update_()
- {
- mln_precondition(is_valid());
- mln_precondition(c_->is_valid());
- v_.update_id(c_->ith_nbh_vertex(i_));
- }
-
- template <typename G>
- template <typename C>
- inline
- void
- vertex_nbh_vertex_bkd_iterator<G>::center_at(const C& c)
- {
- internal::get_adr(c_, c);
- mln_precondition(c_ != 0);
-
- invalidate();
- }
-
-# endif // !MLN_INCLUDE_ONLY
-
- } // End of namespace mln::internal
-
-} // End of namespace mln
-
-
-#endif // !MLN_UTIL_INTERNAL_GRAPH_VERTEX_NBH_VERTEX_ITER_HH
-
--
1.5.6.5
1
0