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
October 2008
- 14 participants
- 373 discussions
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
---
ChangeLog | 16 +
milena/mln/core/concept/graph.hh | 2 +-
milena/mln/util/graph.hh | 304 ++++++++++++++++++-
milena/mln/util/internal/graph_base.hh | 326 +++-----------------
milena/mln/util/internal/graph_edge.hh | 50 ++--
milena/mln/util/internal/graph_edge_iter.hh | 10 +-
.../mln/util/internal/graph_edge_nbh_edge_iter.hh | 4 +-
milena/mln/util/internal/graph_vertex.hh | 86 ++++--
milena/mln/util/internal/graph_vertex_iter.hh | 20 +-
.../util/internal/graph_vertex_nbh_edge_iter.hh | 4 +-
.../util/internal/graph_vertex_nbh_vertex_iter.hh | 4 +-
11 files changed, 463 insertions(+), 363 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 5e7c1a2..a01d9c9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,21 @@
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,
diff --git a/milena/mln/core/concept/graph.hh b/milena/mln/core/concept/graph.hh
index 36d94c9..c98d9e5 100644
--- a/milena/mln/core/concept/graph.hh
+++ b/milena/mln/core/concept/graph.hh
@@ -67,7 +67,7 @@ namespace mln
typedef bkd_piter;
// Misc.
- void *graph_id() const;
+ const E& graph_id() const;
template<typename G2>
bool is_subgraph_of(const G2& gr) const;
diff --git a/milena/mln/util/graph.hh b/milena/mln/util/graph.hh
index b94dabc..765c07c 100644
--- a/milena/mln/util/graph.hh
+++ b/milena/mln/util/graph.hh
@@ -37,23 +37,66 @@
# 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/ord_pair.hh>
namespace mln
{
namespace util
{
+ /// Fwd declaration.
+ class graph;
+ }
+
+ namespace internal
+ {
+
+ /// Data structure for \c mln::image2d<T>.
+ template <>
+ struct data<util::graph>
+ {
+ typedef util::graph G;
+ typedef std::vector<std::vector<unsigned> > vertices_t;
+ typedef std::vector<util::ord_pair<unsigned> > edges_t;
+ typedef std::set<util::ord_pair<unsigned> > edges_set_t;
+
+ data();
+ ~data();
+
+ /// The vertices.
+ vertices_t vertices_;
+ /// The edges.
+ edges_t edges_;
+ /// An index of the set of edges, for fast-access purpose.
+ edges_set_t edges_set_;
+ };
+
+ } // end of namespace mln::internal
+
+
+ namespace util
+ {
/// \brief Undirected graph.
class graph : public internal::graph_base<graph>
{
- public:
/// The super class.
typedef internal::graph_base<graph> super;
+ using super::vertex_data_t;
+ using super::edge_data_t;
+
+ public:
+ /// The type of the set of vertices.
+ typedef std::vector<vertex_data_t> vertices_t;
+
+ /// The type of the set of edges.
+ typedef std::vector<edge_data_t> edges_t;
+ /// A set to test the presence of a given edge.
+ typedef std::set<edge_data_t> edges_set_t;
+
/// Iterator types
/// \{
-
/// Vertex iterators
/// \{
typedef mln::internal::vertex_fwd_iterator<graph> vertex_fwd_iter;
@@ -88,13 +131,81 @@ namespace mln
typedef mln::internal::edge_nbh_edge_bkd_iterator<graph> edge_nbh_edge_bkd_iter;
typedef edge_nbh_edge_fwd_iter edge_nbh_edge_iter;
/// \}
+ /// \}
+
+ graph();
+ /// Vertex oriented.
+ /// \{
+ /// Shortcuts factoring the insertion of vertices and edges.
+ /// \{
+ /// \brief Add a vertex.
+ ///
+ /// \return The id of the new vertex.
+ unsigned add_vertex();
+
+ /// Return the vertex whose id is \a v.
+ /// \{
+ vertex_t vertex(unsigned id_v) const;
/// \}
+ /// \brief Return the number of vertices in the graph.
+ size_t v_nmax() const;
+
+ /// Check whether a vertex id \p id_v exists in the graph.
+ bool has_v(unsigned id_v) const;
+
+ /// Return the number of adjacent edges of vertex \p id_v.
+ size_t v_nmax_nbh_edges(unsigned id_v) const;
+
+ /// Returns the \p i th edge adjacent to the vertex \p id_v.
+ unsigned v_ith_nbh_edge(unsigned id_v, unsigned i) const;
+
+ /// Return the number of adjacent vertices of vertex \p id_v.
+ size_t v_nmax_nbh_vertices(unsigned id_v) const;
+
+ /// Returns the \p i th vertex adjacent to the vertex \p id_v.
+ unsigned v_ith_nbh_vertex(unsigned id_v, unsigned i) const;
+ /// \}
+
+
+
+
+ /// Edge oriented.
+ /// \{
+ /// \brief Add an edge.
+ ///
+ /// \return The id of the new edge if it does not exist yet;
+ /// otherwise, return <tt>mln_max(unsigned)</tt>.
+ unsigned add_edge(unsigned id_v1, unsigned id_v2);
+
+ /// Return the edge whose id is \a e.
+ edge_t edge(unsigned e) const;
+
+ /// \brief Return the number of edges in the graph.
+ size_t e_nmax() const;
+
+ /// Return whether \p id_e is in the graph.
+ bool has_e(unsigned id_e) const;
+
+ /// Return the first vertex associated to the edge \p id_e.
+ unsigned v1(unsigned id_e) const;
+
+ /// Return the second vertex associated to edge \p id_e
+ unsigned v2(unsigned id_e) const;
+
+ /// Return the number max of adjacent edge, given an edge \p id_e.
+ size_t e_nmax_nbh_edges(unsigned id_e) const;
+
+ /// Return the \p i th edge adjacent to the edge \p id_e.
+ unsigned e_ith_nbh_edge(unsigned id_e, unsigned i) const;
+
/// Return whether this graph is a subgraph
/// Return always false here.
template <typename G2>
bool is_subgraph_of(const G2& g) const;
+ /// \}
+
};
} // end of namespace mln::util
@@ -107,9 +218,198 @@ namespace mln
namespace mln
{
+ namespace internal
+ {
+
+ inline
+ data<util::graph>::data()
+ {
+ }
+
+ inline
+ data<util::graph>::~data()
+ {
+ }
+
+ } // end of namespace mln::internal
+
namespace util
{
+ inline
+ graph::graph()
+ {
+ this->data_ = new mln::internal::data<util::graph>();
+ }
+
+ /*---------------.
+ | Vertex related |
+ `---------------*/
+
+ inline
+ unsigned
+ graph::add_vertex()
+ {
+ /* FIXME: This is not thread-proof (these two lines should
+ form an atomic section). */
+ data_->vertices_.resize(data_->vertices_.size() + 1);
+
+ return v_nmax() - 1;
+ }
+
+ inline
+ graph::vertex_t
+ graph::vertex(unsigned id_v) const
+ {
+ mln_assertion(has_v(id_v));
+ return vertex_t(*this, id_v);
+ }
+
+
+ inline
+ size_t
+ graph::v_nmax() const
+ {
+ return data_->vertices_.size();
+ }
+
+ inline
+ bool
+ graph::has_v(unsigned id_v) const
+ {
+ return id_v < data_->vertices_.size();
+ }
+
+ inline
+ size_t
+ graph::v_nmax_nbh_edges(unsigned id_v) const
+ {
+ mln_precondition(has_v(id_v));
+ return data_->vertices_[id_v].size();
+ }
+
+ inline
+ unsigned
+ graph::v_ith_nbh_edge(unsigned id_v, unsigned i) const
+ {
+ mln_precondition(has_v(id_v));
+ if (i >= v_nmax_nbh_edges(id_v))
+ return v_nmax();
+ return data_->vertices_[id_v][i];
+ }
+
+ inline
+ size_t
+ graph::v_nmax_nbh_vertices(unsigned id_v) const
+ {
+ mln_precondition(has_v(id_v));
+ return v_nmax_nbh_edges(id_v);
+ }
+
+ inline
+ unsigned
+ graph::v_ith_nbh_vertex(unsigned id_v, unsigned i) const
+ {
+ mln_precondition(has_v(id_v));
+
+ unsigned id_e = v_ith_nbh_edge(id_v, i);
+ return v_other(id_e, id_v);
+ }
+
+
+ /*--------------.
+ | Edges related |
+ `---------------*/
+
+ inline
+ unsigned
+ graph::add_edge(unsigned id_v1, unsigned id_v2)
+ {
+ // Does this edge already exist in the graph?
+ edge_data_t edge(id_v1, id_v2);
+ if (data_->edges_set_.find(edge) != data_->edges_set_.end ())
+ {
+ // Return the erroneous value.
+ return mln_max(unsigned);
+ }
+ else
+ {
+ // Otherwise insert it into the graph.
+ /* FIXME: This is not thread-proof (these two lines should
+ form an atomic section). */
+ data_->edges_.push_back(edge);
+ unsigned id = data_->edges_.size() - 1;
+
+ // Update the set of edges.
+ data_->edges_set_.insert(edge);
+ data_->vertices_[edge.first()].push_back(id);
+ data_->vertices_[edge.second()].push_back(id);
+
+ return id;
+ }
+ }
+
+ inline
+ graph::edge_t
+ graph::edge(unsigned e) const
+ {
+ mln_assertion(e < e_nmax());
+ return edge_t(*this, e);
+ }
+
+ inline
+ size_t
+ graph::e_nmax() const
+ {
+ return data_->edges_.size();
+ }
+
+ inline
+ bool
+ graph::has_e(unsigned id_e) const
+ {
+ return id_e < data_->edges_.size();
+ }
+
+ inline
+ unsigned
+ graph::v1(unsigned id_e) const
+ {
+ mln_precondition(has_e(id_e));
+ return data_->edges_[id_e].first();
+ }
+
+ inline
+ unsigned
+ graph::v2(unsigned id_e) const
+ {
+ mln_precondition(has_e(id_e));
+ return data_->edges_[id_e].second();
+ }
+
+ inline
+ size_t
+ graph::e_nmax_nbh_edges(unsigned id_e) const
+ {
+ mln_precondition(has_e(id_e));
+ return v_nmax_nbh_edges(v1(id_e)) + v_nmax_nbh_edges(v2(id_e));
+ }
+
+ inline
+ unsigned
+ graph::e_ith_nbh_edge(unsigned id_e, unsigned i) const
+ {
+ mln_precondition(has_e(id_e));
+ if (i >= e_nmax_nbh_edges(id_e))
+ return e_nmax();
+
+ unsigned v1_nmax = v_nmax_nbh_edges(v1(id_e));
+ if (i < v1_nmax)
+ return v_ith_nbh_edge(v1(id_e), i);
+ return v_ith_nbh_edge(v2(id_e), i - v1_nmax);
+ }
+
+
template <typename G2>
inline
bool
diff --git a/milena/mln/util/internal/graph_base.hh b/milena/mln/util/internal/graph_base.hh
index 9f2e6e2..d98c6ff 100644
--- a/milena/mln/util/internal/graph_base.hh
+++ b/milena/mln/util/internal/graph_base.hh
@@ -42,12 +42,13 @@
# include <mln/core/concept/object.hh>
# include <mln/core/concept/graph.hh>
# include <mln/core/concept/proxy.hh>
-
-# include <mln/util/ord_pair.hh>
-# include <mln/value/builtin/integers.hh>
+# include <mln/core/internal/data.hh>
# include <mln/util/internal/graph_edge.hh>
# include <mln/util/internal/graph_vertex.hh>
+# include <mln/util/ord_pair.hh>
+# include <mln/util/tracked_ptr.hh>
+
namespace mln
{
@@ -65,21 +66,17 @@ namespace mln
template<typename E>
class graph_base : public Graph<E>
{
+
+ protected:
/// The type of a vertex.
typedef util::vertex<E> vertex_t;
/// Internal vertex data type
typedef std::vector<unsigned> vertex_data_t;
- /// The type of the set of vertices.
- typedef std::vector<vertex_data_t> vertices_t;
/// The type of an edge.
typedef util::edge<E> edge_t;
/// Internal edge data type.
typedef ord_pair<unsigned> edge_data_t;
- /// The type of the set of edges.
- typedef std::vector<edge_data_t> edges_t;
- /// A set to test the presence of a given edge.
- typedef std::set<edge_data_t> edges_set_t;
public:
/// Misc. methods
@@ -88,87 +85,24 @@ namespace mln
const void * const graph_id() const;
/// \}
- /// Vertex and edge oriented methods.
- /// \{
- /// Returns the other adjacent vertex id of a given edge id \p id_e.
- unsigned v_other(unsigned id_e, unsigned id_v) const;
- /// \}
-
-
- /// Vertex oriented.
- /// \{
-
- /// Shortcuts factoring the insertion of vertices and edges.
+ /// Vertex oriented methods
/// \{
- /// \brief Add a vertex.
- ///
- /// \return The id of the new vertex.
- unsigned add_vertex();
-
- /// Return the vertex whose id is \a v.
- /// \{
- vertex_t vertex(unsigned id_v) const;
- /// \}
-
- /// \brief Return the number of vertices in the graph.
- size_t v_nmax() const;
-
/// Check whether a vertex \p v exists in the graph.
bool has(const util::vertex<E>& v) const;
- /// Check whether a vertex id \p id_v exists in the graph.
- bool has_v(unsigned id_v) const;
-
- /// Return the number of adjacent edges of vertex \p id_v.
- size_t v_nmax_nbh_edges(unsigned id_v) const;
-
- /// Returns the \p i th edge adjacent to the vertex \p id_v.
- unsigned v_ith_nbh_edge(unsigned id_v, unsigned i) const;
-
- /// Return the number of adjacent vertices of vertex \p id_v.
- size_t v_nmax_nbh_vertices(unsigned id_v) const;
-
- /// Returns the \p i th vertex adjacent to the vertex \p id_v.
- unsigned v_ith_nbh_vertex(unsigned id_v, unsigned i) const;
-
- /// \}
-
-
- /// Edge oriented.
- /// \{
- /// \brief Add an edge.
- ///
- /// \return The id of the new edge if it does not exist yet;
- /// otherwise, return <tt>mln_max(unsigned)</tt>.
- unsigned add_edge(unsigned id_v1, unsigned id_v2);
/// \}
- /// Return the edge whose id is \a e.
+ /// Edge oriented methods
/// \{
- const edge_t& edge(unsigned e) const;
- /// \}
-
- /// \brief Return the number of edges in the graph.
- size_t e_nmax() const;
-
/// Check whether an edge \p e exists in the graph.
bool has(const util::edge<E>& e) const;
+ /// \}
- /// Return whether \p id_e is in the graph.
- bool has_e(unsigned id_e) const;
-
- /// Return the first vertex associated to the edge \p id_e.
- unsigned v1(unsigned id_e) const;
-
- /// Return the second vertex associated to edge \p id_e
- unsigned v2(unsigned id_e) const;
-
- /// Return the number max of adjacent edge, given an edge \p id_e.
- size_t e_nmax_nbh_edges(unsigned id_e) const;
-
- /// Return the \p i th edge adjacent to the edge \p id_e.
- unsigned e_ith_nbh_edge(unsigned id_e, unsigned i) const;
+ /// Vertex and edge oriented methods.
+ /// \{
+ /// Returns the other adjacent vertex id of a given edge id \p id_e.
+ unsigned v_other(unsigned id_e, unsigned id_v) const;
/// \}
// FIXME: We might want to externalize this in routine of
@@ -182,20 +116,11 @@ namespace mln
protected:
- /// The vertices.
- vertices_t vertices_;
- /// The edges.
- edges_t edges_;
- /// An index of the set of edges, for fast-access purpose.
- edges_set_t edges_set_;
+ /// Internal data, sharable by several graphs.
+ util::tracked_ptr< mln::internal::data<E> > data_;
- /// Construction, assignments and destruction.
- /// \{
+ /// Constructor
graph_base<E>();
- //graph_base<E>(const self_t& rhs);
- //self_t& operator=(const self_t& rhs);
- //~graph_base<E>();
- /// \}
};
@@ -217,7 +142,6 @@ namespace mln
template<typename E>
inline
graph_base<E>::graph_base()
- : vertices_(), edges_(), edges_set_()
{
}
@@ -230,7 +154,7 @@ namespace mln
const void * const
graph_base<E>::graph_id() const
{
- return this;
+ return static_cast<const void * const>(data_.ptr_);
}
/*-------------------------.
@@ -242,15 +166,15 @@ namespace mln
unsigned
graph_base<E>::v_other(unsigned id_e, unsigned id_v) const
{
- mln_precondition(has_e(id_e));
- mln_precondition(has_v(id_v));
- mln_precondition(edges_[id_e].first() == id_v
- || edges_[id_e].second() == id_v);
-
- const edge_data_t& e = edges_[id_e];
- if (e.first() == id_v)
- return e.second();
- return e.first();
+ const E *g = exact(this);
+ mln_precondition(g->has_e(id_e));
+ mln_precondition(g->has_v(id_v));
+ mln_precondition(g->v1(id_e) == id_v
+ || g->v2(id_e) == id_v);
+
+ if (g->v1(id_e) == id_v)
+ return g->v2(id_e);
+ return g->v1(id_e);
}
/*---------------.
@@ -259,201 +183,24 @@ namespace mln
template<typename E>
inline
- unsigned
- graph_base<E>::add_vertex()
- {
- /* FIXME: This is not thread-proof (these two lines should
- form an atomic section). */
- vertices_.resize(vertices_.size() + 1);
-
- return vertices_.size() - 1;
- }
-
- template<typename E>
- inline
- typename graph_base<E>::vertex_t
- graph_base<E>::vertex(unsigned id_v) const
- {
- mln_assertion(has_v(id_v));
-
- return vertex_t(this, id_v);
- }
-
- template<typename E>
- inline
- size_t
- graph_base<E>::v_nmax() const
- {
- return vertices_.size();
- }
-
- template<typename E>
- inline
bool
graph_base<E>::has(const util::vertex<E>& v) const
{
return has_v(v.id());
}
- template<typename E>
- inline
- bool
- graph_base<E>::has_v(unsigned id_v) const
- {
- return id_v < vertices_.size();
- }
-
- template<typename E>
- inline
- size_t
- graph_base<E>::v_nmax_nbh_edges(unsigned id_v) const
- {
- mln_precondition(has_v(id_v));
-
- return vertices_[id_v].size();
- }
-
- template<typename E>
- inline
- unsigned
- graph_base<E>::v_ith_nbh_edge(unsigned id_v, unsigned i) const
- {
- mln_precondition(has_v(id_v));
- if (i >= v_nmax_nbh_edges(id_v))
- return v_nmax();
-
- return vertices_[id_v][i];
- }
-
- template<typename E>
- inline
- size_t
- graph_base<E>::v_nmax_nbh_vertices(unsigned id_v) const
- {
- mln_precondition(has_v(id_v));
- return v_nmax_nbh_edges(id_v);
- }
-
- template<typename E>
- inline
- unsigned
- graph_base<E>::v_ith_nbh_vertex(unsigned id_v, unsigned i) const
- {
- mln_precondition(has_v(id_v));
-
- unsigned id_e = v_ith_nbh_edge(id_v, i);
- return v_other(id_e, id_v);
- }
-
-
/*--------------.
| Edges related |
`---------------*/
template<typename E>
inline
- unsigned
- graph_base<E>::add_edge(unsigned id_v1, unsigned id_v2)
- {
- // Does this edge already exist in the graph?
- edge_data_t edge(id_v1, id_v2);
- if (edges_set_.find(edge) != edges_set_.end ())
- {
- // Return the erroneous value.
- return mln_max(unsigned);
- }
- else
- {
- // Otherwise insert it into the graph.
- /* FIXME: This is not thread-proof (these two lines should
- form an atomic section). */
- edges_.push_back(edge);
- unsigned id = edges_.size() - 1;
-
- // Update the set of edges.
- edges_set_.insert(edge);
- vertices_[edge.first()].push_back(id);
- vertices_[edge.second()].push_back(id);
-
- return id;
- }
- }
-
- template<typename E>
- inline
- const typename graph_base<E>::edge_t&
- graph_base<E>::edge(unsigned e) const
- {
- mln_assertion(e < this->nedges());
- return edge_t(this, edges_[e].first(), edges_[e].second());
- }
-
- template<typename E>
- inline
- size_t
- graph_base<E>::e_nmax() const
- {
- return edges_.size();
- }
-
- template<typename E>
- inline
bool
graph_base<E>::has(const util::edge<E>& e) const
{
return has_e(e.id());
}
- template<typename E>
- inline
- bool
- graph_base<E>::has_e(unsigned id_e) const
- {
- return id_e < edges_.size();
- }
-
- template<typename E>
- inline
- unsigned
- graph_base<E>::v1(unsigned id_e) const
- {
- mln_precondition(has_e(id_e));
- return edges_[id_e].first();
- }
-
- template<typename E>
- inline
- unsigned
- graph_base<E>::v2(unsigned id_e) const
- {
- mln_precondition(has_e(id_e));
- return edges_[id_e].second();
- }
-
- template<typename E>
- inline
- size_t
- graph_base<E>::e_nmax_nbh_edges(unsigned id_e) const
- {
- mln_precondition(has_e(id_e));
- return v_nmax_nbh_edges(v1(id_e)) + v_nmax_nbh_edges(v2(id_e));
- }
-
- template<typename E>
- inline
- unsigned
- graph_base<E>::e_ith_nbh_edge(unsigned id_e, unsigned i) const
- {
- mln_precondition(has_e(id_e));
- if (i >= e_nmax_nbh_edges(id_e))
- return e_nmax();
-
- unsigned v1_nmax = v_nmax_nbh_edges(v1(id_e));
- if (i < v1_nmax)
- return v_ith_nbh_edge(v1(id_e), i);
- return v_ith_nbh_edge(v2(id_e), i - v1_nmax);
- }
-
/*--------.
| Debug. |
`--------*/
@@ -463,26 +210,25 @@ namespace mln
void
graph_base<E>::print_debug (std::ostream& ostr) const
{
+ const E *g = exact(this);
+
ostr << "graph: " << std::endl;
- for (unsigned v = 0; v < vertices_.size(); ++v)
+ for (unsigned v = 0; v < g->v_nmax(); ++v)
{
ostr << "vertex: " << v << std::endl << " -- adjacent vertices: ";
- for (vertex_data_t::const_iterator e =
- vertices_[v].begin(); e != vertices_[v].end();
- ++e)
- if (v == edges_[*e].first())
- ostr << edges_[*e].second() << " ";
- else
- ostr << edges_[*e].first() << " ";
+ for (int n = 0; n < g->v_nmax_nbh_vertices(v); ++n)
+ ostr << g->v_ith_nbh_vertex(v, n) << " ";
ostr << std::endl;
}
ostr << std::endl;
ostr << "edges:" << std::endl;
unsigned ei = 0;
- for (edges_t::const_iterator e = edges_.begin(); e != edges_.end();
- ++e, ++ei)
- ostr << "edge " << ei << ": (" << e->first() << ", " << e->second() << " )" << std::endl;
+ for (int i = 0; i < g->e_nmax(); ++i)
+ ostr << "edge " << i << ": ("
+ << g->v1(i) << ", "
+ << g->v2(i) << " )"
+ << std::endl;
}
} // end of namespace mln::util::internal
diff --git a/milena/mln/util/internal/graph_edge.hh b/milena/mln/util/internal/graph_edge.hh
index d878685..dcbf6ac 100644
--- a/milena/mln/util/internal/graph_edge.hh
+++ b/milena/mln/util/internal/graph_edge.hh
@@ -48,14 +48,14 @@ namespace mln
template <typename G>
class edge : public internal::edge_impl_<G>
{
- typedef mlc_const(G) graph_t;
+ typedef mlc_unconst(G) graph_t;
public:
/// Constructors
/// \{
edge();
- explicit edge(graph_t *g);
- edge(graph_t *g, unsigned id);
+ explicit edge(const graph_t& g);
+ edge(const graph_t& g, unsigned id);
/// \}
@@ -68,8 +68,8 @@ namespace mln
/// Set id_ with \p id;
void update_id(unsigned id);
- /// Return pointer of the graph holding this edge.
- const graph_t * g() const;
+ /// Return a reference to the graph holding this edge.
+ const graph_t& g() const;
/// Set g_ with \p g;
void change_graph(const graph_t& g);
@@ -102,7 +102,7 @@ namespace mln
/// \}
private:
- graph_t * g_;
+ graph_t g_;
unsigned id_;
};
@@ -126,7 +126,7 @@ namespace mln
struct subject_impl< const util::edge<G>, E >
{
unsigned id() const;
- const mlc_const(G) * g() const;
+ const mlc_const(G)& g() const;
unsigned v_other(unsigned id_v) const;
bool is_valid() const;
unsigned v1() const;
@@ -172,17 +172,17 @@ namespace mln
template <typename G>
inline
- edge<G>::edge(graph_t *g)
- : g_(g), id_(g->e_nmax())
+ edge<G>::edge(const graph_t& g)
+ : g_(g), id_(g.e_nmax())
{
}
template <typename G>
inline
- edge<G>::edge(graph_t *g, unsigned id)
+ edge<G>::edge(const graph_t& g, unsigned id)
: g_(g), id_(id)
{
- mln_precondition(g->has_e(id));
+ mln_precondition(g.has_e(id));
}
template <typename G>
@@ -203,7 +203,7 @@ namespace mln
template <typename G>
inline
- const typename edge<G>::graph_t *
+ const typename edge<G>::graph_t&
edge<G>::g() const
{
return g_;
@@ -214,7 +214,7 @@ namespace mln
void
edge<G>::change_graph(const graph_t& g)
{
- g_ = & g;
+ g_ = g;
}
template <typename G>
@@ -223,7 +223,7 @@ namespace mln
edge<G>::v_other(unsigned id_v) const
{
mln_precondition(v1() == id_v || v2() == id_v);
- return g_->v_other(id_, id_v);
+ return g_.v_other(id_, id_v);
}
template <typename G>
@@ -231,7 +231,7 @@ namespace mln
bool
edge<G>::is_valid() const
{
- return g_ != 0 && g_->has_e(id_);
+ return g_.has_e(id_);
}
template <typename G>
@@ -239,8 +239,8 @@ namespace mln
unsigned
edge<G>::v1() const
{
- mln_precondition(g_->has_e(id_));
- return g_->v1(id_);
+ mln_precondition(g_.has_e(id_));
+ return g_.v1(id_);
}
template <typename G>
@@ -248,8 +248,8 @@ namespace mln
unsigned
edge<G>::v2() const
{
- mln_precondition(g_->has_e(id_));
- return g_->v2(id_);
+ mln_precondition(g_.has_e(id_));
+ return g_.v2(id_);
}
template <typename G>
@@ -257,8 +257,8 @@ namespace mln
size_t
edge<G>::nmax_nbh_edges() const
{
- mln_precondition(g_->has_e(id_));
- return g_->e_nmax_nbh_edges(id_);
+ mln_precondition(g_.has_e(id_));
+ return g_.e_nmax_nbh_edges(id_);
}
template <typename G>
@@ -266,8 +266,8 @@ namespace mln
unsigned
edge<G>::ith_nbh_edge(unsigned i) const
{
- mln_precondition(g_->has_e(id_));
- return g_->e_ith_nbh_edge(id_, i);
+ mln_precondition(g_.has_e(id_));
+ return g_.e_ith_nbh_edge(id_, i);
}
@@ -315,7 +315,7 @@ namespace mln
template <typename G, typename E>
inline
- const mlc_const(G) *
+ const mlc_const(G)&
subject_impl< const util::edge<G>, E >::g() const
{
return exact_().get_subject().g();
@@ -387,7 +387,7 @@ namespace mln
void
subject_impl< util::edge<G>, E >::change_graph(const mlc_const(G)& g)
{
- return exact_().get_subject().change_graph(&g);
+ return exact_().get_subject().change_graph(g);
}
} // End of namespace mln::internal
diff --git a/milena/mln/util/internal/graph_edge_iter.hh b/milena/mln/util/internal/graph_edge_iter.hh
index 9bcf9ff..b3d83de 100644
--- a/milena/mln/util/internal/graph_edge_iter.hh
+++ b/milena/mln/util/internal/graph_edge_iter.hh
@@ -142,7 +142,7 @@ namespace mln
template <typename G>
inline
edge_fwd_iterator<G>::edge_fwd_iterator(const G& g)
- : e_(util::edge<G>(&g))
+ : e_(util::edge<G>(g))
{
invalidate();
}
@@ -160,7 +160,7 @@ namespace mln
void
edge_fwd_iterator<G>::invalidate()
{
- e_.update_id(e_.g()->e_nmax());
+ e_.update_id(e_.g().e_nmax());
}
template <typename G>
@@ -210,7 +210,7 @@ namespace mln
template <typename G>
inline
edge_bkd_iterator<G>::edge_bkd_iterator(const G& g)
- : e_(util::edge<G>(&g))
+ : e_(util::edge<G>(g))
{
invalidate();
}
@@ -228,7 +228,7 @@ namespace mln
void
edge_bkd_iterator<G>::invalidate()
{
- e_.update_id(e_.g()->e_nmax());
+ e_.update_id(e_.g().e_nmax());
}
template <typename G>
@@ -236,7 +236,7 @@ namespace mln
void
edge_bkd_iterator<G>::start()
{
- e_.update_id(e_.g()->e_nmax() - 1);
+ e_.update_id(e_.g().e_nmax() - 1);
}
template <typename G>
diff --git a/milena/mln/util/internal/graph_edge_nbh_edge_iter.hh b/milena/mln/util/internal/graph_edge_nbh_edge_iter.hh
index 084ad23..3ba8d0e 100644
--- a/milena/mln/util/internal/graph_edge_nbh_edge_iter.hh
+++ b/milena/mln/util/internal/graph_edge_nbh_edge_iter.hh
@@ -158,7 +158,7 @@ namespace mln
void
edge_nbh_edge_fwd_iterator<G>::invalidate()
{
- i_ = e_.g()->e_nmax();
+ i_ = e_.g().e_nmax();
}
template <typename G>
@@ -256,7 +256,7 @@ namespace mln
void
edge_nbh_edge_bkd_iterator<G>::invalidate()
{
- i_ = e_.g()->e_nmax();
+ i_ = e_.g().e_nmax();
}
template <typename G>
diff --git a/milena/mln/util/internal/graph_vertex.hh b/milena/mln/util/internal/graph_vertex.hh
index 8d35282..61b589f 100644
--- a/milena/mln/util/internal/graph_vertex.hh
+++ b/milena/mln/util/internal/graph_vertex.hh
@@ -43,15 +43,15 @@ namespace mln
template<typename G>
class vertex : public internal::vertex_impl_<G>
{
- typedef mlc_const(G) graph_t;
+ typedef mlc_unconst(G) graph_t;
public:
/// Constructors.
/// \{
vertex();
- explicit vertex(graph_t *g);
- vertex(graph_t *g, unsigned id);
+ explicit vertex(const graph_t& g);
+ vertex(const graph_t& g, unsigned id);
/// \}
/// Check whether the vertex is still part of the graph.
@@ -82,16 +82,26 @@ namespace mln
void update_id(unsigned id);
/// Returns the graph pointer this vertex belongs to.
- const graph_t * g() const;
+ const graph_t& g() const;
/// Returns vertex id.
unsigned id() const;
- private:
- graph_t * g_;
+ protected:
+ graph_t g_;
unsigned id_;
};
+ /// Comparison operator. Test whether two vertices have the same id.
+ template<typename G>
+ bool
+ operator==(const util::vertex<G>& v1, const util::vertex<G>& v2);
+
+ /// Inferior operator. Test whether lhs.id() < rhs.id().
+ template<typename G>
+ bool
+ operator<(const util::vertex<G>& lhs, const util::vertex<G>& rhs);
+
} // End of namespace mln::util
@@ -103,7 +113,7 @@ namespace mln
struct subject_impl< const util::vertex<G>, E >
{
bool is_valid() const;
- const mlc_const(G) * g() const;
+ const mlc_const(G)& g() const;
unsigned id() const;
unsigned other(unsigned id_e) const;
@@ -142,26 +152,44 @@ namespace mln
namespace util
{
+ template<typename G>
+ inline
+ bool
+ operator==(const util::vertex<G>& v1, const util::vertex<G>& v2)
+ {
+ return v1.id() == v2.id();
+ }
+
+ template<typename G>
+ inline
+ bool
+ operator<(const util::vertex<G>& lhs, const util::vertex<G>& rhs)
+ {
+ return lhs.id() < rhs.id();
+ }
+
+
+
template <typename G>
inline
vertex<G>::vertex()
- : g_(0), id_(0)
+ : id_(0)
{
}
template <typename G>
inline
- vertex<G>::vertex(graph_t *g)
- : g_(g), id_(g_->v_nmax())
+ vertex<G>::vertex(const graph_t& g)
+ : g_(g), id_(g_.v_nmax())
{
}
template<typename G>
inline
- vertex<G>::vertex(graph_t *g, unsigned id)
+ vertex<G>::vertex(const graph_t& g, unsigned id)
: g_(g), id_(id)
{
- mln_precondition(g_->has_v(id));
+ mln_precondition(g_.has_v(id));
}
template<typename G>
@@ -169,7 +197,7 @@ namespace mln
bool
vertex<G>::is_valid() const
{
- return g_ != 0 && g_->has_v(id_);
+ return g_.has_v(id_);
}
template<typename G>
@@ -177,7 +205,7 @@ namespace mln
void
vertex<G>::invalidate()
{
- id_ = g_->v_nmax();
+ id_ = g_.v_nmax();
}
@@ -186,10 +214,10 @@ namespace mln
unsigned
vertex<G>::other(unsigned id_e) const
{
- mln_precondition(g_->has_v(id_));
- mln_precondition(g_->has_e(id_e));
- mln_precondition(g_->v1(id_e) == id_ || g_->v2(id_e) == id_);
- return g_->v_other(id_e, id_);
+ mln_precondition(g_.has_v(id_));
+ mln_precondition(g_.has_e(id_e));
+ mln_precondition(g_.v1(id_e) == id_ || g_.v2(id_e) == id_);
+ return g_.v_other(id_e, id_);
}
template<typename G>
@@ -197,8 +225,8 @@ namespace mln
unsigned
vertex<G>::ith_nbh_edge(unsigned i) const
{
- mln_precondition(g_->has_v(id_));
- return g_->v_ith_nbh_edge(id_, i);
+ mln_precondition(g_.has_v(id_));
+ return g_.v_ith_nbh_edge(id_, i);
}
template<typename G>
@@ -206,8 +234,8 @@ namespace mln
unsigned
vertex<G>::nmax_nbh_edges() const
{
- mln_precondition(g_->has_v(id_));
- return g_->v_nmax_nbh_edges(id_);
+ mln_precondition(g_.has_v(id_));
+ return g_.v_nmax_nbh_edges(id_);
}
template<typename G>
@@ -215,8 +243,8 @@ namespace mln
unsigned
vertex<G>::ith_nbh_vertex(unsigned i) const
{
- mln_precondition(g_->has_v(id_));
- return g_->v_ith_nbh_vertex(id_, i);
+ mln_precondition(g_.has_v(id_));
+ return g_.v_ith_nbh_vertex(id_, i);
}
template<typename G>
@@ -224,8 +252,8 @@ namespace mln
unsigned
vertex<G>::nmax_nbh_vertices() const
{
- mln_precondition(g_->has_v(id_));
- return g_->v_nmax_nbh_vertices(id_);
+ mln_precondition(g_.has_v(id_));
+ return g_.v_nmax_nbh_vertices(id_);
}
template<typename G>
@@ -233,7 +261,7 @@ namespace mln
void
vertex<G>::change_graph(const G& g)
{
- g_ = &g;
+ g_ = g;
}
template<typename G>
@@ -246,7 +274,7 @@ namespace mln
template<typename G>
inline
- const typename vertex<G>::graph_t *
+ const typename vertex<G>::graph_t&
vertex<G>::g() const
{
return g_;
@@ -283,7 +311,7 @@ namespace mln
template <typename G, typename E>
inline
- const mlc_const(G)*
+ const mlc_const(G)&
subject_impl< const util::vertex<G>, E >::g() const
{
return exact_().get_subject().g();
diff --git a/milena/mln/util/internal/graph_vertex_iter.hh b/milena/mln/util/internal/graph_vertex_iter.hh
index da564e7..d77611f 100644
--- a/milena/mln/util/internal/graph_vertex_iter.hh
+++ b/milena/mln/util/internal/graph_vertex_iter.hh
@@ -108,6 +108,8 @@ namespace mln
/// Go to the next value.
void next();
+ void update_graph(const G& g);
+
/// Return current index
unsigned index() const;
/// \}
@@ -156,7 +158,7 @@ namespace mln
void
vertex_fwd_iterator<G>::invalidate()
{
- v_.update_id(v_.g()->v_nmax());
+ v_.update_id(v_.g().v_nmax());
}
template<typename G>
@@ -180,7 +182,7 @@ namespace mln
void
vertex_fwd_iterator<G>::update_graph(const G& g)
{
- v_ = util::vertex<G>(&g);
+ v_ = util::vertex<G>(g);
}
template<typename G>
@@ -213,8 +215,8 @@ namespace mln
template<typename G>
inline
vertex_bkd_iterator<G>::vertex_bkd_iterator(const G& g)
- : v_(util::vertex<G>(&g))
{
+ update_graph(g);
invalidate();
}
@@ -231,7 +233,7 @@ namespace mln
void
vertex_bkd_iterator<G>::invalidate()
{
- v_.update_id(v_.g()->v_nmax());
+ v_.update_id(v_.g().v_nmax());
}
template<typename G>
@@ -239,7 +241,7 @@ namespace mln
void
vertex_bkd_iterator<G>::start()
{
- v_.update_id(v_.g()->v_nmax() - 1);
+ v_.update_id(v_.g().v_nmax() - 1);
}
template<typename G>
@@ -252,6 +254,14 @@ namespace mln
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
{
diff --git a/milena/mln/util/internal/graph_vertex_nbh_edge_iter.hh b/milena/mln/util/internal/graph_vertex_nbh_edge_iter.hh
index 4edc652..634dc07 100644
--- a/milena/mln/util/internal/graph_vertex_nbh_edge_iter.hh
+++ b/milena/mln/util/internal/graph_vertex_nbh_edge_iter.hh
@@ -157,7 +157,7 @@ namespace mln
void
vertex_nbh_edge_fwd_iterator<G>::invalidate()
{
- i_ = e_.g()->e_nmax();
+ i_ = e_.g().e_nmax();
}
template <typename G>
@@ -249,7 +249,7 @@ namespace mln
void
vertex_nbh_edge_bkd_iterator<G>::invalidate()
{
- e_.update_id(e_.g()->e_nmax());
+ e_.update_id(e_.g().e_nmax());
}
template <typename G>
diff --git a/milena/mln/util/internal/graph_vertex_nbh_vertex_iter.hh b/milena/mln/util/internal/graph_vertex_nbh_vertex_iter.hh
index d51bc29..0dc87b5 100644
--- a/milena/mln/util/internal/graph_vertex_nbh_vertex_iter.hh
+++ b/milena/mln/util/internal/graph_vertex_nbh_vertex_iter.hh
@@ -158,7 +158,7 @@ namespace mln
void
vertex_nbh_vertex_fwd_iterator<G>::invalidate()
{
- i_ = v_.g()->v_nmax();
+ i_ = v_.g().v_nmax();
}
template <typename G>
@@ -248,7 +248,7 @@ namespace mln
void
vertex_nbh_vertex_bkd_iterator<G>::invalidate()
{
- v_.update_id(v_.g()->e_nmax());
+ v_.update_id(v_.g().e_nmax());
}
template <typename G>
--
1.5.6.5
1
0
---
ChangeLog | 19 +++++++++++++++++++
.../tutorial/samples/borderthickness-output.tex | 13 +++++++++++++
milena/doc/tutorial/samples/borderthickness.tex | 8 ++++++++
milena/doc/tutorial/samples/extension-ignore.tex | 1 +
milena/doc/tutorial/samples/extension-ignore2.tex | 1 +
milena/doc/tutorial/samples/ima-load.tex | 6 ++++++
milena/doc/tutorial/samples/ima-save.tex | 9 +++++++++
milena/doc/tutorial/samples/ima-size-output.tex | 1 +
milena/doc/tutorial/samples/ima-size.tex | 11 +++++++++++
milena/doc/tutorial/samples/ima2d-1-output.tex | 2 ++
milena/doc/tutorial/samples/ima2d-3-output.tex | 6 ++++++
.../doc/tutorial/samples/paste-call-1-output.tex | 3 +++
milena/doc/tutorial/samples/point-1-output.tex | 2 ++
milena/doc/tutorial/tutorial.tex | 1 +
14 files changed, 83 insertions(+), 0 deletions(-)
create mode 100644 milena/doc/tutorial/samples/borderthickness-output.tex
create mode 100644 milena/doc/tutorial/samples/borderthickness.tex
create mode 100644 milena/doc/tutorial/samples/extension-ignore.tex
create mode 100644 milena/doc/tutorial/samples/extension-ignore2.tex
create mode 100644 milena/doc/tutorial/samples/ima-load.tex
create mode 100644 milena/doc/tutorial/samples/ima-save.tex
create mode 100644 milena/doc/tutorial/samples/ima-size-output.tex
create mode 100644 milena/doc/tutorial/samples/ima-size.tex
create mode 100644 milena/doc/tutorial/samples/ima2d-1-output.tex
create mode 100644 milena/doc/tutorial/samples/ima2d-3-output.tex
create mode 100644 milena/doc/tutorial/samples/paste-call-1-output.tex
create mode 100644 milena/doc/tutorial/samples/point-1-output.tex
diff --git a/ChangeLog b/ChangeLog
index a94185c..5e7c1a2 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,22 @@
+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.
diff --git a/milena/doc/tutorial/samples/borderthickness-output.tex b/milena/doc/tutorial/samples/borderthickness-output.tex
new file mode 100644
index 0000000..e1db166
--- /dev/null
+++ b/milena/doc/tutorial/samples/borderthickness-output.tex
@@ -0,0 +1,13 @@
+ima_def - border = 3
+- - - - - - - -
+- - - - - - - -
+- - - - - - - -
+- - - - | - - -
+- - - | - - - -
+- - - - - - - -
+- - - - - - - -
+- - - - - - - -
+
+ima_bt0 - border = 0
+- |
+| -
diff --git a/milena/doc/tutorial/samples/borderthickness.tex b/milena/doc/tutorial/samples/borderthickness.tex
new file mode 100644
index 0000000..d491f16
--- /dev/null
+++ b/milena/doc/tutorial/samples/borderthickness.tex
@@ -0,0 +1,8 @@
+bool vals[2][2] = { {0, 1},
+ {1, 0} };
+image2d<bool> ima_def = make::image2d(vals);
+display::format(ima_def);
+
+border::thickness = 0;
+image2d<bool> ima_bt0 = make::image2d(vals);
+display::format(ima_bt0);
diff --git a/milena/doc/tutorial/samples/extension-ignore.tex b/milena/doc/tutorial/samples/extension-ignore.tex
new file mode 100644
index 0000000..a8d0be5
--- /dev/null
+++ b/milena/doc/tutorial/samples/extension-ignore.tex
@@ -0,0 +1 @@
+my_routine(ima | ima.domain());
diff --git a/milena/doc/tutorial/samples/extension-ignore2.tex b/milena/doc/tutorial/samples/extension-ignore2.tex
new file mode 100644
index 0000000..7e7ef54
--- /dev/null
+++ b/milena/doc/tutorial/samples/extension-ignore2.tex
@@ -0,0 +1 @@
+my_routine(ima.domain());
diff --git a/milena/doc/tutorial/samples/ima-load.tex b/milena/doc/tutorial/samples/ima-load.tex
new file mode 100644
index 0000000..e4a68ee
--- /dev/null
+++ b/milena/doc/tutorial/samples/ima-load.tex
@@ -0,0 +1,6 @@
+# include <mln/core/io/pbm/load.hh>
+int main()
+{
+ mln::image2d<bool> ima;
+ io::pbm::load(ima, "my_image.pbm");
+}
diff --git a/milena/doc/tutorial/samples/ima-save.tex b/milena/doc/tutorial/samples/ima-save.tex
new file mode 100644
index 0000000..47086e2
--- /dev/null
+++ b/milena/doc/tutorial/samples/ima-save.tex
@@ -0,0 +1,9 @@
+# include <mln/core/io/pgm/save.hh>
+int main()
+{
+ mln::image2d<mln::value::int_u8> ima;
+
+ // ...
+
+ io::pgm::save(ima, "my_image.pgm");
+}
diff --git a/milena/doc/tutorial/samples/ima-size-output.tex b/milena/doc/tutorial/samples/ima-size-output.tex
new file mode 100644
index 0000000..6be445f
--- /dev/null
+++ b/milena/doc/tutorial/samples/ima-size-output.tex
@@ -0,0 +1 @@
+nrows = 10 - ncols = 12
diff --git a/milena/doc/tutorial/samples/ima-size.tex b/milena/doc/tutorial/samples/ima-size.tex
new file mode 100644
index 0000000..46d5a08
--- /dev/null
+++ b/milena/doc/tutorial/samples/ima-size.tex
@@ -0,0 +1,11 @@
+#include <core/image/image2d.hh>
+#include <core/site_set/box2d.hh>
+int main()
+{
+ mln::image2d<int> ima(box2d(0,0, 10,12));
+
+ std::cout << "nrows = " << ima.nrows()
+ << " - "
+ << "ncols = " << ima.ncols()
+ << std::endl;
+}
diff --git a/milena/doc/tutorial/samples/ima2d-1-output.tex b/milena/doc/tutorial/samples/ima2d-1-output.tex
new file mode 100644
index 0000000..e689fa5
--- /dev/null
+++ b/milena/doc/tutorial/samples/ima2d-1-output.tex
@@ -0,0 +1,2 @@
+b = [(-2,3)...(3,-5)]
+domain = [(-2,3)...(3,-5)]
diff --git a/milena/doc/tutorial/samples/ima2d-3-output.tex b/milena/doc/tutorial/samples/ima2d-3-output.tex
new file mode 100644
index 0000000..096ef4f
--- /dev/null
+++ b/milena/doc/tutorial/samples/ima2d-3-output.tex
@@ -0,0 +1,6 @@
+ima.at(1,2) = 9
+ima(p) = 9
+---
+ima.at(1,2) = 2
+ima(p) = 2
+
diff --git a/milena/doc/tutorial/samples/paste-call-1-output.tex b/milena/doc/tutorial/samples/paste-call-1-output.tex
new file mode 100644
index 0000000..987bf30
--- /dev/null
+++ b/milena/doc/tutorial/samples/paste-call-1-output.tex
@@ -0,0 +1,3 @@
+b b b b
+b b b b
+b b b b
diff --git a/milena/doc/tutorial/samples/point-1-output.tex b/milena/doc/tutorial/samples/point-1-output.tex
new file mode 100644
index 0000000..d5a3da6
--- /dev/null
+++ b/milena/doc/tutorial/samples/point-1-output.tex
@@ -0,0 +1,2 @@
+has(p1)? true
+has(p2)? false
diff --git a/milena/doc/tutorial/tutorial.tex b/milena/doc/tutorial/tutorial.tex
index f675045..2e7ddfe 100644
--- a/milena/doc/tutorial/tutorial.tex
+++ b/milena/doc/tutorial/tutorial.tex
@@ -80,6 +80,7 @@ showstringspaces=false,linewidth=14cm}
- \backslash subpage winneigh
- \backslash subpage sitesandco
- \backslash subpage iterators
+- \backslash subpage imamemmgmt
- \backslash subpage basicops
- \backslash subpage graphes
\backslash htmlonly
--
1.5.6.5
1
0