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
December 2008
- 12 participants
- 201 discussions
31 Dec '08
* tests/morpho/Makefile.am: re-enable all tests.
* tests/morpho/artificial_line_graph_image_wst.cc,
* tests/morpho/graph_image_morpho.cc,
* tests/morpho/graph_image_wst.cc,
* tests/morpho/lena_line_graph_image_wst1.cc,
* tests/morpho/lena_line_graph_image_wst2.cc,
* tests/morpho/line_graph_image_morpho.cc,
* tests/morpho/line_graph_image_wst.cc: update according the new graph
structures.
---
milena/ChangeLog | 15 +++
milena/tests/morpho/Makefile.am | 35 +++---
.../morpho/artificial_line_graph_image_wst.cc | 40 ++++----
milena/tests/morpho/graph_image_morpho.cc | 99 ++++++++----------
milena/tests/morpho/graph_image_wst.cc | 78 ++++++++------
milena/tests/morpho/lena_line_graph_image_wst1.cc | 89 ++++++++--------
milena/tests/morpho/lena_line_graph_image_wst2.cc | 37 +++----
milena/tests/morpho/line_graph_image_morpho.cc | 91 ++++++++--------
milena/tests/morpho/line_graph_image_wst.cc | 115 +++++++++++---------
9 files changed, 311 insertions(+), 288 deletions(-)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index c42010f..8952f82 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,5 +1,20 @@
2008-12-31 Guillaume Lazzara <z(a)lrde.epita.fr>
+ Re-enable tests in morpho and make them work again.
+
+ * tests/morpho/Makefile.am: re-enable all tests.
+
+ * tests/morpho/artificial_line_graph_image_wst.cc,
+ * tests/morpho/graph_image_morpho.cc,
+ * tests/morpho/graph_image_wst.cc,
+ * tests/morpho/lena_line_graph_image_wst1.cc,
+ * tests/morpho/lena_line_graph_image_wst2.cc,
+ * tests/morpho/line_graph_image_morpho.cc,
+ * tests/morpho/line_graph_image_wst.cc: update according the new graph
+ structures.
+
+2008-12-31 Guillaume Lazzara <z(a)lrde.epita.fr>
+
Re-enable tools/area_flooding.
* tools/Makefile.am: enable the target.
diff --git a/milena/tests/morpho/Makefile.am b/milena/tests/morpho/Makefile.am
index a8f12ab..003ba6f 100644
--- a/milena/tests/morpho/Makefile.am
+++ b/milena/tests/morpho/Makefile.am
@@ -2,13 +2,12 @@
include $(top_srcdir)/milena/tests/tests.mk
-##FIXME: re-enable all tests
SUBDIRS = \
elementary \
tree
check_PROGRAMS = \
-## artificial_line_graph_image_wst \
+ artificial_line_graph_image_wst \
closing_area \
closing_height \
closing_volume \
@@ -20,14 +19,14 @@ check_PROGRAMS = \
erosion \
general \
gradient \
-## graph_image_morpho \
-## graph_image_wst \
+ graph_image_morpho \
+ graph_image_wst \
hit_or_miss \
laplacian \
-## lena_line_graph_image_wst1 \
-## lena_line_graph_image_wst2 \
-## line_graph_image_wst \
-## line_graph_image_morpho \
+ lena_line_graph_image_wst1 \
+ lena_line_graph_image_wst2 \
+ line_graph_image_wst \
+ line_graph_image_morpho \
meyer_wst \
meyer_wst_long \
opening_area \
@@ -58,11 +57,11 @@ hit_or_miss_SOURCES = hit_or_miss.cc
laplacian_SOURCES = laplacian.cc
thinning_SOURCES = thinning.cc
-##graph_image_morpho_SOURCES = graph_image_morpho.cc
-##graph_image_wst_SOURCES = graph_image_wst.cc
+graph_image_morpho_SOURCES = graph_image_morpho.cc
+graph_image_wst_SOURCES = graph_image_wst.cc
-##line_graph_image_morpho_SOURCES = line_graph_image_morpho.cc
-##line_graph_image_wst_SOURCES = line_graph_image_wst.cc
+line_graph_image_morpho_SOURCES = line_graph_image_morpho.cc
+line_graph_image_wst_SOURCES = line_graph_image_wst.cc
complex_image_morpho_SOURCES = complex_image_morpho.cc
complex_image_wst_SOURCES = complex_image_wst.cc
@@ -79,17 +78,17 @@ combined_SOURCES = combined.cc
# Complex tests. #
# --------------- #
-##artificial_line_graph_image_wst_SOURCES = artificial_line_graph_image_wst.cc
-##artificial_line_graph_image_wst_CXXFLAGS = $(TESTS_CXXFLAGS_SPEED)
+artificial_line_graph_image_wst_SOURCES = artificial_line_graph_image_wst.cc
+artificial_line_graph_image_wst_CXXFLAGS = $(TESTS_CXXFLAGS_SPEED)
dilation_SOURCES = dilation.cc
dilation_CXXFLAGS = $(TESTS_CXXFLAGS_SPEED)
-##lena_line_graph_image_wst1_SOURCES = lena_line_graph_image_wst1.cc
-##lena_line_graph_image_wst1_CXXFLAGS = $(TESTS_CXXFLAGS_SPEED)
+lena_line_graph_image_wst1_SOURCES = lena_line_graph_image_wst1.cc
+lena_line_graph_image_wst1_CXXFLAGS = $(TESTS_CXXFLAGS_SPEED)
-##lena_line_graph_image_wst2_SOURCES = lena_line_graph_image_wst2.cc
-##lena_line_graph_image_wst2_CXXFLAGS = $(TESTS_CXXFLAGS_SPEED)
+lena_line_graph_image_wst2_SOURCES = lena_line_graph_image_wst2.cc
+lena_line_graph_image_wst2_CXXFLAGS = $(TESTS_CXXFLAGS_SPEED)
meyer_wst_long_SOURCES = meyer_wst_long.cc
meyer_wst_long_CXXFLAGS = $(TESTS_CXXFLAGS_SPEED)
diff --git a/milena/tests/morpho/artificial_line_graph_image_wst.cc b/milena/tests/morpho/artificial_line_graph_image_wst.cc
index ebdfaa1..c88ac15 100644
--- a/milena/tests/morpho/artificial_line_graph_image_wst.cc
+++ b/milena/tests/morpho/artificial_line_graph_image_wst.cc
@@ -47,16 +47,18 @@
in it, interpolating inter-pixel points;
\li print the watershed on lines into that same image, and save it. */
-#include <vector>
-
#include <mln/core/image/image2d.hh>
#include <mln/core/alias/point2d.hh>
#include <mln/core/alias/window2d.hh>
#include <mln/core/alias/neighb2d.hh>
-#include <mln/core/image/line_graph_image.hh>
-#include <mln/core/image/line_graph_elt_neighborhood.hh>
-#include <mln/core/image/line_graph_neighborhood_piter.hh>
+/// Required for line graph images.
+#include <mln/core/site_set/p_edges.hh>
+#include <mln/core/image/line_graph_elt_window.hh>
+#include <mln/core/var.hh>
+#include <mln/pw/all.hh>
+#include <mln/fun/i2v/array.hh>
+#include <mln/util/graph.hh>
#include <mln/morpho/line_gradient.hh>
#include <mln/morpho/closing_area_on_vertices.hh>
@@ -114,27 +116,25 @@ int main()
`----------------*/
// Line graph image.
- typedef line_graph_image<point2d, input_val_t> ima_t;
- ima_t lg_ima = morpho::line_gradient(input);
+ mln_VAR(lg_ima, morpho::line_gradient(input));
/*------.
| WST. |
`------*/
- typedef line_graph_elt_neighborhood<point2d> nbh_t;
- nbh_t nbh;
+ typedef line_graph_elt_window<util::graph, lg_ima_t::pset::fun_t> win_t;
+ win_t win;
+ neighb<win_t> nbh(win);
// Perform a Watershed Transform.
- typedef unsigned wst_val_t;
- wst_val_t nbasins;
- typedef line_graph_image<point2d, wst_val_t> wst_ima_t;
- wst_ima_t wshed = morpho::meyer_wst(lg_ima, nbh, nbasins);
+ unsigned nbasins;
+ mln_VAR(wshed, morpho::meyer_wst(lg_ima, nbh, nbasins));
std::cout << "nbasins = " << nbasins << std::endl;
/*---------.
| Output. |
`---------*/
-
+
// FIXME: Inlined conversion, to be reifed into a routine.
// Save the result in gray levels (data) + color (wshed).
@@ -179,12 +179,12 @@ int main()
/* FIXME: We should draw the watershed on another image and
superimpose it on OUTPUT instead of drawing it directly into
OUTPUT. */
- mln_piter_(wst_ima_t) pw(wshed.domain());
+ mln_piter_(wshed_t) pw(wshed.domain());
for_all(pw)
{
if (wshed(pw) == 0)
{
- mln_psite_(wst_ima_t) pp(pw);
+ mln_psite_(lg_ima_t) pp(pw);
// Equivalent of the line (edge) PP in OUTPUT.
int row1 = pp.first()[0] * 2;
int col1 = pp.first()[1] * 2;
@@ -192,7 +192,7 @@ int main()
int col2 = pp.second()[1] * 2;
point2d q((row1 + row2) / 2, (col1 + col2) / 2);
// Print the watershed in red.
- output(q) = literal::red;
+ output(q) = literal::red;
}
}
// Fill the holes, so that the watershed looks connected.
@@ -212,13 +212,13 @@ int main()
// two or more, consider, create a watershed point.
/* FIXME: Iterating over a c4 window would be more elegant, of
course. */
- unsigned nwsheds =
- (output.has(p_out + up ) && output(p_out + up ) == literal::red) +
+ unsigned nwsheds =
+ (output.has(p_out + up ) && output(p_out + up ) == literal::red) +
(output.has(p_out + down ) && output(p_out + down ) == literal::red) +
(output.has(p_out + left ) && output(p_out + right) == literal::red) +
(output.has(p_out + right) && output(p_out + left ) == literal::red);
if (nwsheds >= 2)
- output(p_out) = literal::red;
+ output(p_out) = literal::red;
}
io::ppm::save(output, "out.ppm");
}
diff --git a/milena/tests/morpho/graph_image_morpho.cc b/milena/tests/morpho/graph_image_morpho.cc
index 664533c..8552061 100644
--- a/milena/tests/morpho/graph_image_morpho.cc
+++ b/milena/tests/morpho/graph_image_morpho.cc
@@ -26,45 +26,29 @@
// Public License.
/// \file tests/morpho/graph_image_morpho.cc
-/// \brief Tests on mln::graph_image with morphological filters.
-
-#include <vector>
+///
+/// Tests on mln::graph_image with morphological filters.
#include <mln/accu/bbox.hh>
#include <mln/core/alias/box2d.hh>
#include <mln/core/alias/point2d.hh>
-#include <mln/core/image/graph_elt_window.hh>
-#include <mln/core/image/graph_window_piter.hh>
-#include <mln/core/var.hh>
#include <mln/morpho/dilation.hh>
#include <mln/morpho/erosion.hh>
-#include <mln/util/graph.hh>
-
+/// Required for graph images.
+#include <mln/core/site_set/p_vertices.hh>
+#include <mln/core/image/graph_elt_window.hh>
+#include <mln/core/var.hh>
#include <mln/pw/all.hh>
+#include <mln/fun/i2v/array.hh>
+#include <mln/util/graph.hh>
#include <mln/debug/draw_graph.hh>
#include <mln/debug/iota.hh>
#include <mln/debug/println.hh>
-template <typename S>
-struct vertex_site_value_t : public mln::Function_p2v< vertex_site_value_t<S> >
-{
- typedef unsigned result;
-
- unsigned
- operator()(const mln_psite(S)& p) const
- {
- return v_[p.v().id()];
- }
-
- protected:
- std::vector<result> v_;
-};
-
-
int main()
{
using namespace mln;
@@ -87,20 +71,21 @@ int main()
*/
// Points associated to vertices.
- typedef fun::i2v::array<point2d> F;
- F points(5);
- points(0) = point2d(0,0); // Point associated to vertex 0.
- points(1) = point2d(2,2); // Point associated to vertex 1.
- points(2) = point2d(0,4); // Point associated to vertex 2.
- points(3) = point2d(4,3); // Point associated to vertex 3.
- points(4) = point2d(4,4); // Point associated to vertex 4.
-
- // Edges.
- typedef mln::util::graph G;
- G g;
+ typedef fun::i2v::array<point2d> fsite_t;
+ fsite_t sites(5);
+ sites(0) = point2d(0,0); // Point associated to vertex 0.
+ sites(1) = point2d(2,2); // Point associated to vertex 1.
+ sites(2) = point2d(0,4); // Point associated to vertex 2.
+ sites(3) = point2d(4,3); // Point associated to vertex 3.
+ sites(4) = point2d(4,4); // Point associated to vertex 4.
+
+ // Graph.
+ util::graph g;
+
// Populate the graph with vertices.
- for (unsigned i = 0; i < points.size(); ++i)
- g.add_vertex ();
+ for (unsigned i = 0; i < sites.size(); ++i)
+ g.add_vertex();
+
// Populate the graph with edges.
g.add_edge(0, 1);
g.add_edge(1, 2);
@@ -108,21 +93,26 @@ int main()
g.add_edge(3, 4);
g.add_edge(4, 2);
+
/*----------------------.
| Graph image support. |
`----------------------*/
- p_vertices<G, F> pg(g, points);
+ typedef p_vertices<util::graph, fsite_t> pv_t;
+ pv_t pv(g, sites);
/*--------------.
| Graph image. |
`--------------*/
- vertex_site_value_t< p_vertices<G, F> > values;
- // Graph image.
- mln_VAR(ima, (values | pg));
- // Initialize values.
- debug::iota(ima);
+ // Graph values.
+ typedef fun::i2v::array<unsigned> viota_t;
+ viota_t iota(pv.nsites());
+ for (unsigned i = 0; i < iota.size(); ++i)
+ iota(i) = 10 + i;
+
+ // Create graph image.
+ mln_const_VAR(ima, (iota | pv));
/*-------------------------------------.
| Image representation/visualization. |
@@ -132,12 +122,12 @@ int main()
/* FIXME: mln::graph_image should automatically feature a bbox when
its parameter P is akin to a point. */
accu::bbox<point2d> a;
- for (unsigned i = 0; i < points.size(); ++i)
- a.take(points(i));
+ for (unsigned i = 0; i < sites.size(); ++i)
+ a.take(sites(i));
box2d bbox = a.to_result();
// Print the image.
/* FIXME: Unfortunately, displaying graph images is not easy right
- now (2008-02-05). We could use
+ now (2008-02-05). We could use
debug::println(ima);
@@ -146,7 +136,7 @@ int main()
interface of graph_image to work with points (not psites).
Moreover, this implementation only shows *values*, not the graph
itslef.
-
+
An alternative is to use draw::graph (which, again, is misnamed),
but it doesn't show the values, only the vertices and edges of the
graph.
@@ -159,14 +149,13 @@ int main()
| Processing graph images. |
`--------------------------*/
- typedef graph_elt_window<G, F> win_t;
- win_t win;
+ graph_elt_window<util::graph, fsite_t> win;
- image2d<unsigned> ima_dil = morpho::dilation(ima, win);
-// debug::draw_graph(ima_rep, ima_dil, 9);
-// debug::println(ima_rep);
+ mln_const_VAR(ima_dil, morpho::dilation(ima, win));
+ debug::draw_graph(ima_rep, ima_dil.domain(), pw::cst(9), pw::cst(2));
+ debug::println(ima_rep);
- image2d<unsigned> ima_ero = morpho::erosion(ima, win);
-// draw::graph(ima_rep, ima_ero, 9);
-// debug::println(ima_rep);
+ mln_const_VAR(ima_ero, morpho::erosion(ima, win));
+ debug::draw_graph(ima_rep, ima_ero.domain(), pw::cst(9), pw::cst(2));
+ debug::println(ima_rep);
}
diff --git a/milena/tests/morpho/graph_image_wst.cc b/milena/tests/morpho/graph_image_wst.cc
index 41dcd5e..53f78cd 100644
--- a/milena/tests/morpho/graph_image_wst.cc
+++ b/milena/tests/morpho/graph_image_wst.cc
@@ -31,9 +31,15 @@
#include <vector>
#include <mln/core/alias/point2d.hh>
-#include <mln/core/image/graph_image.hh>
-#include <mln/core/image/graph_elt_neighborhood.hh>
-#include <mln/core/image/graph_neighborhood_piter.hh>
+
+/// Required for graph images.
+#include <mln/core/site_set/p_vertices.hh>
+#include <mln/core/image/graph_elt_window.hh>
+#include <mln/core/neighb.hh>
+#include <mln/core/var.hh>
+#include <mln/pw/all.hh>
+#include <mln/fun/i2v/array.hh>
+#include <mln/util/graph.hh>
#include <mln/morpho/meyer_wst.hh>
@@ -60,18 +66,21 @@ int main()
*/
// Points associated to vertices.
- std::vector<point2d> points;
- points.push_back(point2d(0,0)); // Point associated to vertex 0.
- points.push_back(point2d(2,2)); // Point associated to vertex 1.
- points.push_back(point2d(0,4)); // Point associated to vertex 2.
- points.push_back(point2d(4,3)); // Point associated to vertex 3.
- points.push_back(point2d(4,4)); // Point associated to vertex 4.
-
- // Edges.
- util::graph<point2d> g;
+ typedef fun::i2v::array<point2d> fsite_t;
+ fsite_t sites(5);
+ sites(0) = point2d(0,0); // Point associated to vertex 0.
+ sites(1) = point2d(2,2); // Point associated to vertex 1.
+ sites(2) = point2d(0,4); // Point associated to vertex 2.
+ sites(3) = point2d(4,3); // Point associated to vertex 3.
+ sites(4) = point2d(4,4); // Point associated to vertex 4.
+
+ // Graph.
+ util::graph g;
+
// Populate the graph with vertices.
- for (unsigned i = 0; i < points.size(); ++i)
- g.add_vertex (points[i]);
+ for (unsigned i = 0; i < sites.size(); ++i)
+ g.add_vertex();
+
// Populate the graph with edges.
g.add_edge(0, 1);
g.add_edge(1, 2);
@@ -79,42 +88,41 @@ int main()
g.add_edge(3, 4);
g.add_edge(4, 2);
- /*-------.
- | Graph. |
- `-------*/
- p_graph<point2d> pg(g);
+ /*----------------------.
+ | Graph image support. |
+ `----------------------*/
+
+ typedef p_vertices<util::graph, fsite_t> pv_t;
+ pv_t pv(g, sites);
/*-------------.
| Graph image. |
`-------------*/
- // Values.
- std::vector<int> values(5);
- values[0] = 0; // Value associated to vertex 0.
- values[1] = 1; // Value associated to vertex 1.
- values[2] = 2; // Value associated to vertex 2.
- values[3] = 3; // Value associated to vertex 3.
- values[4] = 0; // Value associated to vertex 4.
- // Graph image.
- typedef graph_image<point2d, int> ima_t;
- ima_t ima(pg, values);
+ // Graph values.
+ typedef fun::i2v::array<unsigned> viota_t;
+ viota_t iota(pv.nsites());
+ for (unsigned i = 0; i < iota.size(); ++i)
+ iota(i) = 10 + i;
+
+ // Create graph image.
+ mln_const_VAR(ima, (iota | pv));
/*------.
| WST. |
`------*/
- typedef graph_elt_neighborhood<point2d> nbh_t;
- nbh_t nbh;
+ typedef graph_elt_window<util::graph, fsite_t> win_t;
+ win_t win;
+ neighb<win_t> nbh(win);
- typedef unsigned wst_val_t;
- wst_val_t nbasins;
- typedef graph_image<point2d, wst_val_t> wst_ima_t;
- wst_ima_t wshed = morpho::meyer_wst(ima, nbh, nbasins);
+ unsigned nbasins;
+ mln_const_VAR(wshed, morpho::meyer_wst(ima, nbh, nbasins));
std::cout << "nbasins = " << nbasins << std::endl;
// Manual iteration over the domain of WSHED.
- mln_piter_(wst_ima_t) pw(wshed.domain());
+ mln_piter_(wshed_t) pw(wshed.domain());
for_all (pw)
std::cout << "wshed (" << pw << ") = " << wshed(pw) << std::endl;
}
diff --git a/milena/tests/morpho/lena_line_graph_image_wst1.cc b/milena/tests/morpho/lena_line_graph_image_wst1.cc
index 95a6c07..d897d96 100644
--- a/milena/tests/morpho/lena_line_graph_image_wst1.cc
+++ b/milena/tests/morpho/lena_line_graph_image_wst1.cc
@@ -56,9 +56,15 @@
#include <mln/core/alias/window2d.hh>
#include <mln/core/alias/neighb2d.hh>
-#include <mln/core/image/line_graph_image.hh>
-#include <mln/core/image/line_graph_elt_neighborhood.hh>
-#include <mln/core/image/line_graph_neighborhood_piter.hh>
+#include <mln/convert/to_window.hh>
+
+/// Required for line graph images.
+#include <mln/core/site_set/p_edges.hh>
+#include <mln/core/image/line_graph_elt_window.hh>
+#include <mln/core/var.hh>
+#include <mln/pw/all.hh>
+#include <mln/fun/i2v/array.hh>
+#include <mln/util/graph.hh>
#include <mln/morpho/gradient.hh>
#include <mln/morpho/closing_area.hh>
@@ -75,6 +81,8 @@
#include <mln/math/max.hh>
#include <mln/math/abs.hh>
+#include <mln/util/site_pair.hh>
+
#include "tests/data.hh"
@@ -100,7 +108,7 @@ int main()
// Simplify the input image.
image2d<input_val_t> work(input.domain());
- morpho::closing_area(gradient, c4(), 10, work);
+ work = morpho::closing_area(gradient, c4(), 10);
/*-------------.
| Line graph. |
@@ -108,70 +116,61 @@ int main()
// FIXME: Inlined conversion, to be reifed into a routine.
- util::graph<point2d> g;
+ util::graph g;
// Points.
- /* FIXME: The need for such a structure during the conversion
- exhibits the lack of a service from util::graph (or a another,
- missing tool) regarding the retrieval of vertex ids from
- points. */
- std::map<point2d, util::vertex_id, util::ord<point2d> > points;
- util::vertex_id id = 0;
+ image2d<unsigned> equiv_vertex;
+ initialize(equiv_vertex, work);
// Vertices.
- std::vector<int> vertex_values;
mln_fwd_piter_(image2d<input_val_t>) p(work.domain());
- for_all (p)
- {
- g.add_vertex (p);
- vertex_values.push_back (work(p));
- /* FIXME: ``Guessing'' the id of the point just being inserted
- is bad. util:graph<N,E>::add_vertex should return this
- id. */
- points[p] = id;
- ++id.to_equiv();
- }
+ for_all(p)
+ equiv_vertex(p) = g.add_vertex();
// Edges.
window2d next_c4_win;
next_c4_win.insert(0, 1).insert(1, 0);
- std::vector<int> edge_values;
- mln_fwd_qiter_(window2d) q(next_c4_win, p);
+ typedef fun::i2v::array<int> edge_values_t;
+ typedef fun::i2v::array< util::site_pair<point2d> > edge_sites_t;
+ edge_values_t edge_values;
+ edge_sites_t edge_sites;
+ mln_fwd_qiter_(window2d) q(next_c4_win, p);
for_all (p)
- for_all (q)
- if (work.domain().has(q))
+ for_all(q)
+ if (work.domain().has(q))
{
- g.add_edge(points[p], points[q]);
- edge_values.push_back(math::max(work(p), work(q)));
+ unsigned edge_id = g.add_edge(equiv_vertex(p), equiv_vertex(q));
+ edge_values.resize(edge_values.size() + 1);
+ edge_sites.resize(edge_sites.size() + 1);
+ edge_values(edge_id) = math::max(work(p), work(q));
+ edge_sites(edge_id) = util::site_pair<point2d>(p, q);
}
// Line graph point set.
- p_line_graph<point2d> plg(g);
-
- // Line graph image.
- /* FIXME: Shouldn't we use `input_val_t' instead of plain `int' as value
- type here? */
- typedef line_graph_image<point2d, int> ima_t;
- ima_t lg_ima(plg, vertex_values, edge_values);
+ typedef p_edges<util::graph, edge_sites_t> pe_t;
+ pe_t pe(g, edge_sites);
+
+ // Line graph image
+ typedef pw::image<edge_values_t, pe_t> ima_t;
+ mln_VAR(lg_ima, (edge_values | pe));
/*------.
| WST. |
`------*/
- typedef line_graph_elt_neighborhood<point2d> nbh_t;
- nbh_t nbh;
+ typedef line_graph_elt_window<util::graph, edge_sites_t> win_t;
+ win_t win;
+ neighb<win_t> nbh;
// Perform a Watershed Transform.
- typedef int_u8 wst_val_t;
- wst_val_t nbasins;
- typedef line_graph_image<point2d, wst_val_t> wst_ima_t;
- wst_ima_t wshed = morpho::meyer_wst(lg_ima, nbh, nbasins);
+ int_u8 nbasins;
+ mln_VAR(wshed, morpho::meyer_wst(lg_ima, nbh, nbasins));
std::cout << "nbasins = " << nbasins << std::endl;
/*---------.
| Output. |
`---------*/
-
+
// FIXME: Inlined conversion, to be reifed into a routine.
// Save the result in gray levels (data) + color (wshed).
@@ -216,12 +215,12 @@ int main()
/* FIXME: We should draw the watershed on another image and
superimpose it on OUTPUT instead of drawing it directly into
OUTPUT. */
- mln_piter_(wst_ima_t) pw(wshed.domain());
+ mln_piter_(wshed_t) pw(wshed.domain());
for_all(pw)
{
- if (wshed(pw) == 0)
+ if (wshed(pw) == 0u)
{
- mln_psite_(wst_ima_t) pp(pw);
+ mln_psite_(lg_ima_t) pp(pw);
// Equivalent of the line (edge) PP in OUTPUT.
int row1 = pp.first()[0] * 2;
int col1 = pp.first()[1] * 2;
diff --git a/milena/tests/morpho/lena_line_graph_image_wst2.cc b/milena/tests/morpho/lena_line_graph_image_wst2.cc
index 7283796..de48d35 100644
--- a/milena/tests/morpho/lena_line_graph_image_wst2.cc
+++ b/milena/tests/morpho/lena_line_graph_image_wst2.cc
@@ -33,7 +33,7 @@
/** \file tests/morpho/lena_line_graph_image_wst2.cc
\brief More tests on the Watershed Transform (WST) on a
mln::line_graph_image.
-
+
The scenario is as follows:
\li load a 2-D, gray-level image from a PGM file;
\li convert this 2-D image into a line graph-based one, where values
@@ -49,16 +49,18 @@
in it, interpolating inter-pixel points;
\li print the watershed on lines into that same image, and save it. */
-#include <vector>
-
#include <mln/core/image/image2d.hh>
#include <mln/core/alias/point2d.hh>
#include <mln/core/alias/window2d.hh>
#include <mln/core/alias/neighb2d.hh>
-#include <mln/core/image/line_graph_image.hh>
-#include <mln/core/image/line_graph_elt_neighborhood.hh>
-#include <mln/core/image/line_graph_neighborhood_piter.hh>
+/// Required for line graph images.
+#include <mln/core/site_set/p_edges.hh>
+#include <mln/core/image/line_graph_elt_window.hh>
+#include <mln/core/var.hh>
+#include <mln/pw/all.hh>
+#include <mln/fun/i2v/array.hh>
+#include <mln/util/graph.hh>
#include <mln/morpho/line_gradient.hh>
#include <mln/morpho/closing_area_on_vertices.hh>
@@ -101,34 +103,31 @@ int main()
`----------------*/
// Line graph image.
- typedef line_graph_image<point2d, input_val_t> ima_t;
- ima_t lg_ima = morpho::line_gradient(input);
+ mln_VAR(lg_ima, morpho::line_gradient(input));
/*-----------------.
| Simplification. |
`-----------------*/
- typedef line_graph_elt_neighborhood<point2d> nbh_t;
- nbh_t nbh;
+ typedef line_graph_elt_window<util::graph, lg_ima_t::pset::fun_t> win_t;
+ win_t win;
+ neighb<win_t> nbh(win);
- ima_t closed_lg_ima (lg_ima.domain());
- morpho::closing_area_on_vertices(lg_ima, nbh, 20, closed_lg_ima);
+ mln_VAR(closed_lg_ima, morpho::closing_area_on_vertices(lg_ima, nbh, 20));
/*------.
| WST. |
`------*/
// Perform a Watershed Transform.
- typedef unsigned wst_val_t;
- wst_val_t nbasins;
- typedef line_graph_image<point2d, wst_val_t> wst_ima_t;
- wst_ima_t wshed = morpho::meyer_wst(closed_lg_ima, nbh, nbasins);
+ unsigned nbasins;
+ mln_VAR(wshed, morpho::meyer_wst(closed_lg_ima, nbh, nbasins));
std::cout << "nbasins = " << nbasins << std::endl;
/*---------.
| Output. |
`---------*/
-
+
// FIXME: Inlined conversion, to be reifed into a routine.
// Save the result in gray levels (data) + color (wshed).
@@ -173,12 +172,12 @@ int main()
/* FIXME: We should draw the watershed on another image and
superimpose it on OUTPUT instead of drawing it directly into
OUTPUT. */
- mln_piter_(wst_ima_t) pw(wshed.domain());
+ mln_piter_(wshed_t) pw(wshed.domain());
for_all(pw)
{
if (wshed(pw) == 0)
{
- mln_psite_(wst_ima_t) pp(pw);
+ mln_psite_(lg_ima_t) pp(pw);
// Equivalent of the line (edge) PP in OUTPUT.
int row1 = pp.first()[0] * 2;
int col1 = pp.first()[1] * 2;
diff --git a/milena/tests/morpho/line_graph_image_morpho.cc b/milena/tests/morpho/line_graph_image_morpho.cc
index 43bf66b..ce32528 100644
--- a/milena/tests/morpho/line_graph_image_morpho.cc
+++ b/milena/tests/morpho/line_graph_image_morpho.cc
@@ -26,14 +26,18 @@
// Public License.
/// \file tests/morpho/line_graph_image_morpho.cc
-/// \brief Tests on mln::line_graph_image with morphological filters.
-
-#include <vector>
+///
+/// Tests on mln::line_graph_image with morphological filters.
#include <mln/core/alias/point2d.hh>
-#include <mln/core/image/line_graph_image.hh>
+
+/// Required for line graph images.
+#include <mln/core/site_set/p_edges.hh>
#include <mln/core/image/line_graph_elt_window.hh>
-#include <mln/core/image/line_graph_window_piter.hh>
+#include <mln/core/var.hh>
+#include <mln/pw/all.hh>
+#include <mln/fun/i2v/array.hh>
+#include <mln/util/graph.hh>
#include <mln/morpho/erosion.hh>
#include <mln/morpho/dilation.hh>
@@ -51,7 +55,7 @@ int main()
0 1 2 3 4 0 1 2 3 4
.----------- .-----------
- | |
+ | |
0 | 0 2 0 | * *
1 | \ / | 1 | 0 1 |
2 | 1 | 2 | * 4
@@ -60,19 +64,22 @@ int main()
*/
+ // Graph.
+ util::graph g;
+
// Points associated to vertices.
- std::vector<point2d> points;
- points.push_back(point2d(0,0)); // Point associated to vertex 0.
- points.push_back(point2d(2,2)); // Point associated to vertex 1.
- points.push_back(point2d(0,4)); // Point associated to vertex 2.
- points.push_back(point2d(4,3)); // Point associated to vertex 3.
- points.push_back(point2d(4,4)); // Point associated to vertex 4.
-
- // Edges.
- util::graph<point2d> g;
+ typedef fun::i2v::array<point2d> fsite_t;
+ fsite_t sites(5);
+ sites(0) = point2d(0,0); // Point associated to vertex 0.
+ sites(1) = point2d(2,2); // Point associated to vertex 1.
+ sites(2) = point2d(0,4); // Point associated to vertex 2.
+ sites(3) = point2d(4,3); // Point associated to vertex 3.
+ sites(4) = point2d(4,4); // Point associated to vertex 4.
+
// Populate the graph with vertices.
- for (unsigned i = 0; i < points.size(); ++i)
- g.add_vertex (points[i]);
+ for (unsigned i = 0; i < sites.size(); ++i)
+ g.add_vertex();
+
// Populate the graph with edges.
g.add_edge(0, 1);
g.add_edge(1, 2);
@@ -80,48 +87,44 @@ int main()
g.add_edge(3, 4);
g.add_edge(4, 2);
+
/*---------------------------.
| Line graph image support. |
`---------------------------*/
- p_line_graph<point2d> plg(g);
+ typedef p_edges<util::graph, fsite_t> pe_t;
+ pe_t pe(g, sites);
/*-------------------.
| Line graph image. |
`-------------------*/
- // Values ("empty" vectors).
- std::vector<int> vertex_values(5);
- std::vector<int> edge_values(5);
- // FIXME: hand-made iota's.
- for (unsigned i = 0; i < vertex_values.size(); ++i)
- vertex_values[i] = i;
- for (unsigned i = 0; i < edge_values.size(); ++i)
- edge_values[i] = i;
-
- // Line graph image.
- /* FIXME: We probably don't want to build line_graph_images by hand;
- provide helpers and/or conversion functions. */
- typedef line_graph_image<point2d, int> ima_t;
- ima_t ima(plg, vertex_values, edge_values);
-
- /*--------------------------.
- | Processing graph images. |
- `--------------------------*/
-
- typedef line_graph_elt_window<point2d> win_t;
- win_t win;
-
- line_graph_image<point2d, int> ima_dil = morpho::dilation(ima, win);
+ // Line graph values.
+ typedef fun::i2v::array<unsigned> viota_t;
+ viota_t iota(pe.nsites());
+ for (unsigned i = 0; i < iota.size(); ++i)
+ iota(i) = 10 + i;
+
+ // Create line graph image.
+ mln_const_VAR(ima, (iota | pe));
+
+
+ /*-------------------------------.
+ | Processing line graph images. |
+ `-------------------------------*/
+
+ line_graph_elt_window<util::graph, fsite_t> win;
+
+ mln_const_VAR(ima_dil, morpho::dilation(ima, win));
// Manual iteration over the domain of IMA_DIL.
- mln_piter_(ima_t) p_dil(ima_dil.domain());
+ mln_piter_(ima_dil_t) p_dil(ima_dil.domain());
for_all (p_dil)
std::cout << "ima_dil (" << p_dil << ") = " << ima_dil(p_dil) << std::endl;
std::cout << std::endl;
- line_graph_image<point2d, int> ima_ero = morpho::erosion(ima, win);
+ mln_const_VAR(ima_ero, morpho::erosion(ima, win));
// Manual iteration over the domain of IMA_ERO.
- mln_piter_(ima_t) p_ero(ima_ero.domain());
+ mln_piter_(ima_ero_t) p_ero(ima_ero.domain());
for_all (p_ero)
std::cout << "ima_ero (" << p_ero << ") = " << ima_ero(p_ero) << std::endl;
}
diff --git a/milena/tests/morpho/line_graph_image_wst.cc b/milena/tests/morpho/line_graph_image_wst.cc
index ce6514f..a700d16 100644
--- a/milena/tests/morpho/line_graph_image_wst.cc
+++ b/milena/tests/morpho/line_graph_image_wst.cc
@@ -26,14 +26,19 @@
// Public License.
/// \file tests/morpho/line_graph_image_wst.cc
-/// \brief Tests on the Watershed Transform on a mln::line_graph_image.
-
-#include <vector>
+///
+/// Tests on the Watershed Transform on a mln::line_graph_image.
#include <mln/core/alias/point2d.hh>
-#include <mln/core/image/line_graph_image.hh>
-#include <mln/core/image/line_graph_elt_neighborhood.hh>
-#include <mln/core/image/line_graph_neighborhood_piter.hh>
+
+/// Required for line graph images.
+#include <mln/core/site_set/p_edges.hh>
+#include <mln/core/image/line_graph_elt_window.hh>
+#include <mln/core/neighb.hh>
+#include <mln/core/var.hh>
+#include <mln/pw/all.hh>
+#include <mln/fun/i2v/array.hh>
+#include <mln/util/graph.hh>
#include <mln/morpho/meyer_wst.hh>
@@ -61,45 +66,52 @@ int main()
In G, vertices and egdes are numbered following in the classical
foward order. */
- util::graph<point2d> g;
-
- // Vertices.
- std::vector<int> vertex_values;
- // We don't really care about values on vertices, because the algorithm
- // won't see them. So all are set to 0.
- g.add_vertex (point2d(0, 0)); vertex_values.push_back (0); // Vertex 0.
- g.add_vertex (point2d(0, 1)); vertex_values.push_back (0); // Vertex 1.
- g.add_vertex (point2d(0, 2)); vertex_values.push_back (0); // Vertex 2.
- g.add_vertex (point2d(0, 3)); vertex_values.push_back (0); // Vertex 3.
-
- g.add_vertex (point2d(1, 0)); vertex_values.push_back (0); // Vertex 4.
- g.add_vertex (point2d(1, 1)); vertex_values.push_back (0); // Vertex 5.
- g.add_vertex (point2d(1, 2)); vertex_values.push_back (0); // Vertex 6.
- g.add_vertex (point2d(1, 3)); vertex_values.push_back (0); // Vertex 7.
-
- // Edges.
- std::vector<int> edge_values;
- g.add_edge (0, 1); edge_values.push_back (0);
- g.add_edge (1, 2); edge_values.push_back (10);
- g.add_edge (2, 3); edge_values.push_back (5);
-
- g.add_edge (0, 4); edge_values.push_back (2);
- g.add_edge (1, 5); edge_values.push_back (4);
- g.add_edge (2, 6); edge_values.push_back (6);
- g.add_edge (3, 7); edge_values.push_back (0);
-
- g.add_edge (4, 5); edge_values.push_back (3);
- g.add_edge (5, 6); edge_values.push_back (5);
- g.add_edge (6, 7); edge_values.push_back (2);
-
- // Line graph point set.
- p_line_graph<point2d> plg(g);
-
- // Line graph image.
- /* FIXME: We probably don't want to build line_graph_images by hand;
- provide helpers and/or conversion functions. */
- typedef line_graph_image<point2d, int> ima_t;
- ima_t ima(plg, vertex_values, edge_values);
+ util::graph g;
+
+ // Sites associated to vertices.
+ typedef fun::i2v::array<point2d> fsite_t;
+ fsite_t sites(5);
+ sites(0) = point2d(0,0); // Point associated to vertex 0.
+ sites(1) = point2d(0,1); // Point associated to vertex 1.
+ sites(2) = point2d(0,2); // Point associated to vertex 2.
+ sites(3) = point2d(0,3); // Point associated to vertex 3.
+ sites(4) = point2d(1,0); // Point associated to vertex 4.
+ sites(5) = point2d(1,1); // Point associated to vertex 5.
+ sites(6) = point2d(1,2); // Point associated to vertex 6.
+ sites(7) = point2d(1,3); // Point associated to vertex 7.
+
+ // Populate the graph with vertices.
+ for(unsigned i = 0; i < sites.size(); ++i)
+ g.add_vertex();
+
+ // Populate the graph with edges.
+ g.add_edge(0, 1);
+ g.add_edge(1, 2);
+ g.add_edge(2, 3);
+
+ g.add_edge(0, 4);
+ g.add_edge(1, 5);
+ g.add_edge(2, 6);
+ g.add_edge(3, 7);
+
+ g.add_edge(4, 5);
+ g.add_edge(5, 6);
+ g.add_edge(6, 7);
+
+ typedef p_edges<util::graph, fsite_t> pe_t;
+ pe_t pe(g, sites);
+
+ // Edge values.
+ typedef fun::i2v::array<int> edge_values_t;
+ edge_values_t edge_values(pe.nsites());
+
+ static const int values[] = { 0, 10, 5, 2, 4, 6, 0, 3, 5, 2 };
+ for (unsigned i = 0; i < edge_values.size(); ++i)
+ edge_values(i) = values[i];
+
+ // Create line graph image.
+ mln_const_VAR(ima,(edge_values | pe));
+
/*------------.
| Iterators. |
@@ -111,17 +123,16 @@ int main()
std::cout << "ima (" << p << ") = " << ima(p) << std::endl;
std::cout << std::endl;
- typedef line_graph_elt_neighborhood<point2d> nbh_t;
- nbh_t nbh;
+ typedef line_graph_elt_window<util::graph, fsite_t> win_t;
+ win_t win;
+ neighb<win_t> nbh(win);
- typedef unsigned wst_val_t;
- wst_val_t nbasins;
- typedef line_graph_image<point2d, wst_val_t> wst_ima_t;
- wst_ima_t wshed = morpho::meyer_wst(ima, nbh, nbasins);
+ unsigned nbasins;
+ mln_const_VAR(wshed, morpho::meyer_wst(ima, nbh, nbasins));
std::cout << "nbasins = " << nbasins << std::endl;
// Manual iteration over the domain of WSHED.
- mln_piter_(wst_ima_t) pw(wshed.domain());
+ mln_piter_(wshed_t) pw(wshed.domain());
for_all (pw)
std::cout << "wshed (" << pw << ") = " << wshed(pw) << std::endl;
}
--
1.5.6.5
1
0
* tools/Makefile.am: enable the target.
* tools/area_flooding.cc: update according the new graph structure.
---
milena/ChangeLog | 8 ++++++
milena/tools/Makefile.am | 6 ++--
milena/tools/area_flooding.cc | 57 +++++++++++++++++++++--------------------
3 files changed, 40 insertions(+), 31 deletions(-)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index 0973adf..c42010f 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,5 +1,13 @@
2008-12-31 Guillaume Lazzara <z(a)lrde.epita.fr>
+ Re-enable tools/area_flooding.
+
+ * tools/Makefile.am: enable the target.
+
+ * tools/area_flooding.cc: update according the new graph structure.
+
+2008-12-31 Guillaume Lazzara <z(a)lrde.epita.fr>
+
Fix line_gradient.
* morpho/line_gradient.hh: update according the new graph structure.
diff --git a/milena/tools/Makefile.am b/milena/tools/Makefile.am
index 1d6347c..335f622 100644
--- a/milena/tools/Makefile.am
+++ b/milena/tools/Makefile.am
@@ -3,10 +3,10 @@
include $(top_srcdir)/milena/tools/tools.mk
bin_PROGRAMS = \
- seed2tiling
-#area_flooding
+ seed2tiling \
+ area_flooding
-#area_flooding_SOURCES = area_flooding.cc
+area_flooding_SOURCES = area_flooding.cc
seed2tiling_SOURCES = seed2tiling.cc
# FIXME: Add some tests for these tools.
diff --git a/milena/tools/area_flooding.cc b/milena/tools/area_flooding.cc
index 5d34af0..0157f9c 100644
--- a/milena/tools/area_flooding.cc
+++ b/milena/tools/area_flooding.cc
@@ -25,10 +25,11 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-/** \file tests/morpho/lena_line_graph_image_wst2.cc
- \brief More tests on the Watershed Transform (WST) on a
- mln::line_graph_image.
-
+/// \file tests/morpho/lena_line_graph_image_wst2.cc
+///
+/// More tests on the Watershed Transform (WST) on a
+/// an image base on a p_edges (line_graph_image).
+/*!
The scenario is as follows:
\li load a 2-D, gray-level image from a PGM file;
\li convert this 2-D image into a line graph-based one, where values
@@ -42,6 +43,8 @@
\li create a 2D image of this watershed image, where each basin has
an average grey level of the corresponding region in the input
image.
+
+ FIXME: do not use mln_VAR.
*/
#include <cstdlib>
@@ -55,10 +58,8 @@
#include <mln/core/image/image2d.hh>
#include <mln/core/alias/neighb2d.hh>
-
-#include <mln/core/image/line_graph_image.hh>
-#include <mln/core/image/line_graph_elt_neighborhood.hh>
-#include <mln/core/image/line_graph_neighborhood_piter.hh>
+#include <mln/core/image/line_graph_elt_window.hh>
+#include <mln/core/var.hh>
#include <mln/morpho/line_gradient.hh>
#include <mln/morpho/closing_area_on_vertices.hh>
@@ -92,18 +93,19 @@ int main(int argc, char* argv[])
orig_ima_t input;
io::pgm::load(input, argv[2]);
if (!input.has_data())
- {
- std::cerr << "Error reading input " << argv[2] << std::endl;
- std::exit(2);
- }
+ {
+ std::cerr << "Error reading input " << argv[2] << std::endl;
+ std::exit(2);
+ }
/*----------------.
| Line gradient. |
`----------------*/
// Line graph image.
- typedef line_graph_image<point2d, val_t> ima_t;
- ima_t lg_ima = morpho::line_gradient(input);
+ typedef fun::i2v::array<val_t> fval_t;
+ fval_t values;
+ mln_VAR(lg_ima, morpho::line_gradient(input));
/*-----------.
| Flooding. |
@@ -112,7 +114,7 @@ int main(int argc, char* argv[])
/* FIXME: I'm not sure this is the way it should be done. Anyway,
we should implement this as a canvas. */
- typedef line_graph_elt_neighborhood<point2d> nbh_t;
+ typedef neighb< line_graph_elt_window<util::graph, lg_ima_t::pset::fun_t> > nbh_t;
nbh_t nbh;
unsigned area = 0;
@@ -120,15 +122,15 @@ int main(int argc, char* argv[])
unsigned nregions = mln_max(unsigned);
unsigned max_nregions = atoi(argv[1]);
- ima_t result = duplicate(lg_ima);
+ lg_ima_t result = duplicate(lg_ima);
while (area < max_area && nregions > max_nregions)
{
++area;
std::cerr << "area = " << area << " \t"
<< "nregions = " << nregions << std::endl;
- ima_t work = duplicate(result);
+ lg_ima_t work = duplicate(result);
// Compute the closing.
- morpho::closing_area_on_vertices(work, nbh, area, result);
+ result = morpho::closing_area_on_vertices(work, nbh, area);
// Compute the number of local minima (but get rid of the image,
// as we don't need it).
labeling::regional_minima(result, nbh, nregions);
@@ -141,8 +143,7 @@ int main(int argc, char* argv[])
// Perform a Watershed Transform.
typedef int_u16 wst_val_t;
wst_val_t nbasins;
- typedef line_graph_image<point2d, wst_val_t> wst_ima_t;
- wst_ima_t wshed = morpho::meyer_wst(result, nbh, nbasins);
+ mln_VAR(wshed, morpho::meyer_wst(result, nbh, nbasins));
std::cout << "nbasins = " << nbasins << std::endl;
/*---------.
@@ -153,21 +154,21 @@ int main(int argc, char* argv[])
// Create a 2D-equivalent of WSHED.
image2d<wst_val_t> wshed2d(input.domain());
-
+
/* FIXME: It'd better if we could iterate over the *vertices* of a
line graph image. We could avoid all this lengthy code. */
// Iterate over each edge of the watershed image, and propagate the
// label of an edge to its adjacent vertices when this edge is not
// part of the watershed.
- mln_piter_(wst_ima_t) p(wshed.domain());
+ mln_piter_(wshed_t) p(wshed.domain());
for_all(p)
if (wshed(p) != wshed_label)
- {
- // FIXME: Equip the iterator with first() and second()
- // accessors?
- wshed2d(p.unproxy_().first()) = wshed(p);
- wshed2d(p.unproxy_().second()) = wshed(p);
- }
+ {
+ // FIXME: Equip the iterator with first() and second()
+ // accessors?
+ wshed2d(p.first()) = wshed(p);
+ wshed2d(p.second()) = wshed(p);
+ }
// For each basin, compute the average gray level.
std::vector<mln_sum_(val_t)> sum(nbasins + 1, 0);
--
1.5.6.5
1
0
* morpho/line_gradient.hh: update according the new graph structure.
---
milena/ChangeLog | 6 ++++++
milena/mln/morpho/line_gradient.hh | 26 +++++++++++++-------------
2 files changed, 19 insertions(+), 13 deletions(-)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index 6c23d7b..0973adf 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,5 +1,11 @@
2008-12-31 Guillaume Lazzara <z(a)lrde.epita.fr>
+ Fix line_gradient.
+
+ * morpho/line_gradient.hh: update according the new graph structure.
+
+2008-12-31 Guillaume Lazzara <z(a)lrde.epita.fr>
+
Handle ch_value on graph images and introduce ch_function_value.
* mln/fun/v2v/ch_function_value.hh: new. Wrap a function and
diff --git a/milena/mln/morpho/line_gradient.hh b/milena/mln/morpho/line_gradient.hh
index 1d0128a..bc49df9 100644
--- a/milena/mln/morpho/line_gradient.hh
+++ b/milena/mln/morpho/line_gradient.hh
@@ -50,6 +50,7 @@
# include <mln/util/graph.hh>
# include <mln/util/site_pair.hh>
+
// FIXME: Generalize to other (input) images as well (image1d,
// image3d, etc.).
@@ -63,33 +64,31 @@ namespace mln
/// norm of a mln::image2d.
/* FIXME: Currently, the adjacency is set to 4-c and cannot be
changed. */
- template <typename F, typename S>
- mln::pw::image<F, S>
- line_gradient(const mln::image2d<mln_result(F)>& ima);
+ template <typename V>
+ pw::image<fun::i2v::array<V>, p_edges<util::graph, fun::i2v::array< util::site_pair<point2d> > > >
+ line_gradient(const mln::image2d<V>& ima);
# ifndef MLN_INCLUDE_ONLY
- template <typename F, typename S>
- mln::pw::image<F, S>
- line_gradient(const mln::image2d<mln_result(F)>& ima)
+ template <typename V>
+ pw::image<fun::i2v::array<V>, p_edges<util::graph, fun::i2v::array< util::site_pair<point2d> > > >
+ line_gradient(const mln::image2d<V>& ima)
{
// FIXME: Precondition: Ensure the image is scalar.
- typedef mln_result(F) value_t;
-
util::graph g;
// Vertices.
image2d<unsigned> vpsite(ima.domain());
fun::i2v::array<mln::point2d> fv2p(ima.domain().nsites());
- fun::i2v::array<value_t> vertex_values(ima.domain().nsites());
+ fun::i2v::array<V> vertex_values(ima.domain().nsites());
- mln_fwd_piter(image2d<value_t>) p(ima.domain());
+ mln_fwd_piter(image2d<V>) p(ima.domain());
for_all (p)
{
g.add_vertex();
unsigned id = g.v_nmax() - 1;
- vpsite[p] = id;
+ vpsite(p) = id;
fv2p(id) = p;
}
@@ -97,7 +96,7 @@ namespace mln
// FIXME: The creation of this window should be generic.
window2d next_c4_win;
next_c4_win.insert(0, 1).insert(1, 0);
- typedef fun::i2v::array<value_t> edge_values_t;
+ typedef fun::i2v::array<V> edge_values_t;
typedef fun::i2v::array< util::site_pair<point2d> > edge_sites_t;
edge_values_t edge_values;
edge_sites_t edge_sites;
@@ -110,13 +109,14 @@ namespace mln
// The computed value is a norm of the gradient between P and Q.
unsigned edge_id = edge_values.size();
edge_values.resize(edge_values.size() + 1);
+ edge_sites.resize(edge_sites.size() + 1);
edge_values(edge_id) = math::abs(ima(p) - ima(q));
+ edge_sites(edge_id) = util::site_pair<point2d>(p, q);
}
// Line graph point set.
typedef p_edges<util::graph, edge_sites_t> pe_t;
pe_t plg(g, edge_sites);
-
// Line graph image.
typedef pw::image<edge_values_t, pe_t> ima_t;
ima_t lg_ima = (edge_values | plg);
--
1.5.6.5
1
0
3118: Handle ch_value on graph images and introduce ch_function_value.
by Guillaume Lazzara 31 Dec '08
by Guillaume Lazzara 31 Dec '08
31 Dec '08
* mln/fun/v2v/ch_function_value.hh: new. Wrap a function and
convert that function results to another type thanks to from_to.
* mln/fun/internal/ch_function_value_impl.hh: new. Allow extensions to
ch_function_value according to the function it wraps.
* mln/trait/ch_function_value.hh: Dispatch to the proper way to change
the function return type.
* mln/trait/ch_value.hh: handle ch_value on graph images here.
* headers.mk: add new headers to distribution.
---
milena/ChangeLog | 17 ++++
milena/headers.mk | 3 +
milena/mln/fun/internal/ch_function_value_impl.hh | 57 +++++++++++
milena/mln/fun/v2v/ch_function_value.hh | 106 +++++++++++++++++++++
milena/mln/trait/ch_function_value.hh | 84 ++++++++++++++++
milena/mln/trait/ch_value.hh | 35 ++++++--
6 files changed, 295 insertions(+), 7 deletions(-)
create mode 100644 milena/mln/fun/internal/ch_function_value_impl.hh
create mode 100644 milena/mln/fun/v2v/ch_function_value.hh
create mode 100644 milena/mln/trait/ch_function_value.hh
diff --git a/milena/ChangeLog b/milena/ChangeLog
index 0541e7e..6c23d7b 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,5 +1,22 @@
2008-12-31 Guillaume Lazzara <z(a)lrde.epita.fr>
+ Handle ch_value on graph images and introduce ch_function_value.
+
+ * mln/fun/v2v/ch_function_value.hh: new. Wrap a function and
+ convert that function results to another type thanks to from_to.
+
+ * mln/fun/internal/ch_function_value_impl.hh: new. Allow extensions to
+ ch_function_value according to the function it wraps.
+
+ * mln/trait/ch_function_value.hh: Dispatch to the proper way to change
+ the function return type.
+
+ * mln/trait/ch_value.hh: handle ch_value on graph images here.
+
+ * headers.mk: add new headers to distribution.
+
+2008-12-31 Guillaume Lazzara <z(a)lrde.epita.fr>
+
Fix/improve graph related classes.
* mln/core/image/graph_window_piter.hh: update comments.
diff --git a/milena/headers.mk b/milena/headers.mk
index 8cd49e1..b348a9e 100644
--- a/milena/headers.mk
+++ b/milena/headers.mk
@@ -189,6 +189,7 @@ mln/fun/vv2v/min.hh \
mln/fun/vv2v/essential.hh \
mln/fun/internal/array_base.hh \
mln/fun/internal/x2x_linear_impl.hh \
+mln/fun/internal/ch_function_value_impl.hh \
mln/fun/internal/selector.hh \
mln/fun/v2w_w2v/norm.hh \
mln/fun/p2v/ternary.hh \
@@ -211,6 +212,7 @@ mln/fun/v2v/dec.hh \
mln/fun/v2v/abs.hh \
mln/fun/v2v/rgb_to_hsl.hh \
mln/fun/v2v/cast.hh \
+mln/fun/v2v/ch_function_value.hh \
mln/fun/v2v/rgb_to_hsi.hh \
mln/fun/v2v/enc.hh \
mln/fun/v2v/convert.hh \
@@ -440,6 +442,7 @@ mln/trait/value/essential.hh \
mln/trait/images.hh \
mln/trait/window/props.hh \
mln/trait/window/print.hh \
+mln/trait/ch_function_value.hh \
mln/trait/ch_value.hh \
mln/trait/solve.hh \
mln/trait/solve_unary.hh \
diff --git a/milena/mln/fun/internal/ch_function_value_impl.hh b/milena/mln/fun/internal/ch_function_value_impl.hh
new file mode 100644
index 0000000..fa57290
--- /dev/null
+++ b/milena/mln/fun/internal/ch_function_value_impl.hh
@@ -0,0 +1,57 @@
+// 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_FUN_INTERNAL_CH_FUNCTION_VALUE_IMPL_HH
+# define MLN_FUN_INTERNAL_CH_FUNCTION_VALUE_IMPL_HH
+
+/// \file mln/fun/internal/ch_function_value_impl.hh
+///
+/// Enable the possibility of adding methods to fun::v2v::ch_function_value.
+
+namespace mln
+{
+
+ namespace fun
+ {
+
+ namespace internal
+ {
+
+ /// Default implementation.
+ template <typename F, typename V>
+ struct ch_function_value_impl
+ {
+ };
+
+ } // end of namespace mln::fun::internal
+
+ } // end of namespace mln::fun
+
+} // end of namespace mln
+
+#endif // ! MLN_FUN_INTERNAL_CH_FUNCTION_VALUE_IMPL_HH
diff --git a/milena/mln/fun/v2v/ch_function_value.hh b/milena/mln/fun/v2v/ch_function_value.hh
new file mode 100644
index 0000000..a4c7ca4
--- /dev/null
+++ b/milena/mln/fun/v2v/ch_function_value.hh
@@ -0,0 +1,106 @@
+// 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_FUN_V2V_CH_FUNCTION_VALUE_HH
+# define MLN_FUN_V2V_CH_FUNCTION_VALUE_HH
+
+/// \file mln/fun/v2v/ch_function_value.hh
+///
+/// Wrap a function v2v and convert its result to another type.
+
+# include <mln/core/concept/function.hh>
+# include <mln/convert/to.hh>
+# include <mln/fun/internal/ch_function_value_impl.hh>
+
+
+
+namespace mln
+{
+
+ namespace fun
+ {
+
+ namespace v2v
+ {
+
+ /// Wrap a function v2v and convert its result to another type.
+ template <typename F, typename V>
+ class ch_function_value : public Function_v2v< ch_function_value<F,V> >,
+ public internal::ch_function_value_impl<F, V>
+ {
+ public:
+ typedef F function;
+ typedef V result;
+ typedef V rvalue;
+ typedef V lvalue;
+
+ ch_function_value();
+ ch_function_value(const F& f);
+
+ template <typename W>
+ V operator()(const W& w) const;
+
+ private:
+ F f_;
+ };
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename F, typename V>
+ inline
+ ch_function_value<F,V>::ch_function_value()
+ {
+ }
+
+ template <typename F, typename V>
+ inline
+ ch_function_value<F,V>::ch_function_value(const F& f)
+ {
+ f_ = f;
+ }
+
+ template <typename F, typename V>
+ template <typename W>
+ inline
+ V
+ ch_function_value<F,V>::operator()(const W& w) const
+ {
+ return mln::convert::to<V>(f_(w));
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::fun::v2v
+
+ } // end of namespace mln::fun
+
+} // end of namespace mln
+
+
+#endif // ! MLN_FUN_V2V_CH_FUNCTION_VALUE_HH
diff --git a/milena/mln/trait/ch_function_value.hh b/milena/mln/trait/ch_function_value.hh
new file mode 100644
index 0000000..6ed1e47
--- /dev/null
+++ b/milena/mln/trait/ch_function_value.hh
@@ -0,0 +1,84 @@
+// 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_TRAIT_CH_FUNCTION_VALUE_HH
+# define MLN_TRAIT_CH_FUNCTION_VALUE_HH
+
+/// \file mln/trait/ch_function_value.hh
+///
+/// Definition of the "change value" function trait.
+
+# define mln_ch_function_value(I, V) \
+typename mln::trait::ch_function_value< I, V >::ret
+
+# define mln_ch_function_value_(I, V) \
+mln::trait::ch_functionvalue< I, V >::ret
+
+# include <mln/fun/v2v/ch_function_value.hh>
+
+namespace mln
+{
+
+ namespace trait
+ {
+
+ // Forward declaration.
+ template <typename F, typename V> struct ch_function_value;
+
+
+ namespace impl
+ {
+
+ /// Default.
+ template <typename F, typename VF, typename V>
+ struct ch_function_value
+ {
+ typedef fun::v2v::ch_function_value<F, V> ret;
+ };
+
+ template <typename VF, typename V>
+ struct ch_function_value<fun::i2v::array<VF>, VF, V>
+ {
+ typedef fun::i2v::array<V> ret;
+ };
+
+ } // end of namespace mln::trait::impl
+
+
+ template <typename F, typename V>
+ struct ch_function_value
+ {
+ typedef typename impl::ch_function_value<F, mln_result(F), V>::ret ret;
+ };
+
+
+ } // end of namespace mln::trait
+
+} // end of namespace mln
+
+#endif // ! MLN_TRAIT_CH_FUNCTION_VALUE_HH
diff --git a/milena/mln/trait/ch_value.hh b/milena/mln/trait/ch_value.hh
index 0333a16..cff3a59 100644
--- a/milena/mln/trait/ch_value.hh
+++ b/milena/mln/trait/ch_value.hh
@@ -29,13 +29,13 @@
#ifndef MLN_TRAIT_CH_VALUE_HH
# define MLN_TRAIT_CH_VALUE_HH
-/*! \file mln/trait/ch_value.hh
- *
- * \brief Definition of the "change value" image trait.
- */
+/// \file mln/trait/ch_value.hh
+///
+/// Definition of the "change value" image trait.
# include <mln/tag/skeleton.hh>
# include <mln/trait/image_from_grid.hh>
+# include <mln/trait/ch_function_value.hh>
# define mln_ch_value(I, V) typename mln::trait::ch_value< I, V >::ret
@@ -46,16 +46,18 @@
namespace mln
{
- // Fwd decl.
+ // Forward declarations.
namespace algebra { template <unsigned n, typename T> class vec; }
-
+ template <typename G, typename F> class p_edges;
+ template <typename G, typename F> class p_vertices;
+ namespace pw { template <typename F, typename S> class image; }
namespace trait
{
- // Fwd decl.
+ // Forward declaration.
template <typename I, typename V> struct ch_value;
@@ -163,6 +165,25 @@ namespace mln
typedef typename image_from_grid< grid, V >::ret ret;
};
+ // line_graph image
+ template < typename F,
+ typename G, typename FP,
+ typename V >
+ struct ch_value_< pw::image< tag::function_<F>, tag::pset_<p_edges<G, FP> > >, V >
+ {
+ typedef pw::image< mln_ch_function_value(F, V), p_edges<G, FP> > ret;
+ };
+
+ // graph image
+ template < typename F,
+ typename G, typename FP,
+ typename V >
+ struct ch_value_< pw::image< tag::function_<F>, tag::pset_<p_vertices<G, FP> > >, V >
+ {
+ typedef pw::image< mln_ch_function_value(F, V), p_vertices<G, FP> > ret;
+ };
+
+
template < template <class, class> class M, typename T, typename S,
typename V >
struct ch_value_< M< tag::value_<T>, tag::pset_<S> >, V >
--
1.5.6.5
1
0
* mln/core/image/graph_window_piter.hh: update comments.
* mln/core/internal/graph_window_base.hh: fix the site typedef.
* mln/core/site_set/p_vertices.hh,
* mln/core/site_set/p_edges.hh: add a default constructor. Holds the
graph and not a pointer anymore.
* mln/core/site_set/p_vertices_psite.hh,
* mln/core/site_set/p_edges_psite.hh: add new accessors and a
specialization of subject_impl.
* mln/debug/draw_graph.hh: add a new prototype to draw a graph from a
p_edges.
* mln/util/vertex.hh,
* mln/util/edge.hh: add a new conversion operator towards a graph
element id.
* mln/util/internal/graph_nbh_iter.hh,
* mln/util/internal/graph_iter.hh: some renaming.
* mln/util/internal/graph_nbh_iter_base.hh,
* mln/util/internal/graph_iter_base.hh: add new accessors.
---
milena/ChangeLog | 29 +++++
milena/mln/core/image/graph_window_piter.hh | 4 +-
milena/mln/core/internal/graph_window_base.hh | 3 +-
milena/mln/core/site_set/p_edges.hh | 28 ++++--
milena/mln/core/site_set/p_edges_psite.hh | 92 ++++++++++++++++-
milena/mln/core/site_set/p_vertices.hh | 32 +++---
milena/mln/core/site_set/p_vertices_psite.hh | 52 +++++++++-
milena/mln/debug/draw_graph.hh | 24 +++++
milena/mln/util/edge.hh | 10 ++
milena/mln/util/internal/graph_iter.hh | 16 +--
milena/mln/util/internal/graph_iter_base.hh | 21 ++++
milena/mln/util/internal/graph_nbh_iter.hh | 12 +-
milena/mln/util/internal/graph_nbh_iter_base.hh | 125 +++++++++++++++++------
milena/mln/util/vertex.hh | 10 ++
14 files changed, 377 insertions(+), 81 deletions(-)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index 4d6d70f..0541e7e 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,5 +1,34 @@
2008-12-31 Guillaume Lazzara <z(a)lrde.epita.fr>
+ Fix/improve graph related classes.
+
+ * mln/core/image/graph_window_piter.hh: update comments.
+
+ * mln/core/internal/graph_window_base.hh: fix the site typedef.
+
+ * mln/core/site_set/p_vertices.hh,
+ * mln/core/site_set/p_edges.hh: add a default constructor. Holds the
+ graph and not a pointer anymore.
+
+ * mln/core/site_set/p_vertices_psite.hh,
+ * mln/core/site_set/p_edges_psite.hh: add new accessors and a
+ specialization of subject_impl.
+
+ * mln/debug/draw_graph.hh: add a new prototype to draw a graph from a
+ p_edges.
+
+ * mln/util/vertex.hh,
+ * mln/util/edge.hh: add a new conversion operator towards a graph
+ element id.
+
+ * mln/util/internal/graph_nbh_iter.hh,
+ * mln/util/internal/graph_iter.hh: some renaming.
+
+ * mln/util/internal/graph_nbh_iter_base.hh,
+ * mln/util/internal/graph_iter_base.hh: add new accessors.
+
+2008-12-31 Guillaume Lazzara <z(a)lrde.epita.fr>
+
Various small fixes.
* mln/accu/count_adjacent_vertices.hh: add missing is_valid().
diff --git a/milena/mln/core/image/graph_window_piter.hh b/milena/mln/core/image/graph_window_piter.hh
index a6b29e3..0bd341e 100644
--- a/milena/mln/core/image/graph_window_piter.hh
+++ b/milena/mln/core/image/graph_window_piter.hh
@@ -77,11 +77,11 @@ namespace mln
/// Go to the next point.
void do_next_();
- /// Set the reference psite.
+ /// Do some work while setting the reference site.
template <typename Pref>
void center_at_(const Pref& c);
- /// Set the reference psite.
+ /// Do some work while setting the reference site.
template <typename I2>
void center_at_(const p_graph_piter<S, I2>& c);
diff --git a/milena/mln/core/internal/graph_window_base.hh b/milena/mln/core/internal/graph_window_base.hh
index a72472c..8af7d65 100644
--- a/milena/mln/core/internal/graph_window_base.hh
+++ b/milena/mln/core/internal/graph_window_base.hh
@@ -37,6 +37,7 @@
namespace mln
{
+ /// \tparam P Site type.
template <typename P, typename E>
class graph_window_base : public Window<E>
{
@@ -46,7 +47,7 @@ namespace mln
/// Associated types.
/// \{
/// The type of site corresponding to the window.
- typedef mln_site(P) site;
+ typedef P site;
// FIXME: This is a dummy value.
typedef void dpsite;
diff --git a/milena/mln/core/site_set/p_edges.hh b/milena/mln/core/site_set/p_edges.hh
index b1d46f2..a987e73 100644
--- a/milena/mln/core/site_set/p_edges.hh
+++ b/milena/mln/core/site_set/p_edges.hh
@@ -87,6 +87,8 @@ namespace mln
/// \param gr The graph upon which the graph edge psite set is built.
/// \param f the function mapping edges and sites.
p_edges(const G& gr, const F& f);
+ /// Default constructor.
+ p_edges();
/// Associated types.
/// \{
@@ -106,7 +108,7 @@ namespace mln
typedef fwd_piter piter;
/// \}
- /// \brief Return The number of points (sites) of the set, i.e.,
+ /// Return The number of points (sites) of the set, i.e.,
/// the number of \em edges.
unsigned nsites() const;
@@ -138,12 +140,12 @@ namespace mln
private:
- const G* g_;
+ G g_;
F f_;
};
- /// \brief Comparison between two mln::p_edges's.
+ /// Comparison between two mln::p_edges's.
///
/// Two mln::p_edges's are considered equal if they share the
/// same graph.
@@ -152,7 +154,7 @@ namespace mln
operator==(const p_edges<G, F>& lhs, const p_edges<G, F>& rhs);
- /// \brief Inclusion of a mln::p_edges in another one.
+ /// Inclusion of a mln::p_edges in another one.
///
/// \todo Refine this later, when we are able to express subgraph
/// relations.
@@ -171,7 +173,13 @@ namespace mln
template <typename G, typename F>
inline
p_edges<G, F>::p_edges(const G& g, const F& f)
- : g_ (&g), f_(f)
+ : g_ (g), f_(f)
+ {
+ }
+
+ template <typename G, typename F>
+ inline
+ p_edges<G, F>::p_edges()
{
}
@@ -188,7 +196,7 @@ namespace mln
unsigned
p_edges<G, F>::nedges() const
{
- return this->g_->e_nmax();
+ return this->g_.e_nmax();
}
template <typename G, typename F>
@@ -196,7 +204,7 @@ namespace mln
bool
p_edges<G, F>::is_valid() const
{
- return g_ != 0;
+ return true;/* FIXME: g.is_valid(); */
}
template <typename G, typename F>
@@ -204,7 +212,7 @@ namespace mln
void
p_edges<G, F>::invalidate()
{
- g_ = 0;
+ /* FIXME: g.invalidate(); */
}
template <typename G, typename F>
@@ -223,7 +231,7 @@ namespace mln
p_edges<G, F>::has(const util::edge<G2>& e) const
{
mln_precondition(is_valid());
- return e.graph().is_subgraph_of(*g_) && g_->has(e) && e.is_valid();
+ return e.graph().is_subgraph_of(g_) && g_.has(e) && e.is_valid();
}
template <typename G, typename F>
@@ -242,7 +250,7 @@ namespace mln
p_edges<G, F>::graph() const
{
mln_precondition(is_valid());
- return *g_;
+ return g_;
}
template <typename G, typename F>
diff --git a/milena/mln/core/site_set/p_edges_psite.hh b/milena/mln/core/site_set/p_edges_psite.hh
index 8742b61..902910d 100644
--- a/milena/mln/core/site_set/p_edges_psite.hh
+++ b/milena/mln/core/site_set/p_edges_psite.hh
@@ -41,6 +41,8 @@ namespace mln
// Forward declaration.
template <typename G, typename F> class p_edges;
+ namespace util { template <typename G> class vertex; }
+ namespace internal { template <typename T, typename E> struct subject_impl; }
template <typename G, typename F>
@@ -63,11 +65,39 @@ namespace mln
/// \{
/// Return the underlying edge.
const util::edge<G>& e() const;
+ util::vertex<G> v1() const;
+ util::vertex<G> v2() const;
/// \}
};
+ namespace internal
+ {
+
+ /// Subject_impl (Proxy)
+
+ template <typename G, typename F, typename E>
+ struct subject_impl< const p_edges_psite<G,F>&, E >
+ : subject_impl< const graph_psite_base< p_edges<G,F>,
+ p_edges_psite<G,F> >&, E >
+ {
+ const util::edge<G>& e() const;
+ util::vertex<G> v1() const;
+ util::vertex<G> v2() const;
+ private:
+ const E& exact_() const;
+ };
+
+ template <typename G, typename F, typename E>
+ struct subject_impl< p_edges_psite<G,F>&, E >
+ : subject_impl< const p_edges_psite<G,F>&, E >,
+ subject_impl< graph_psite_base< p_edges<G,F>,
+ p_edges_psite<G,F> >&, E >
+ {
+ };
+
+ } // end of namespace mln::internal
# ifndef MLN_INCLUDE_ONLY
@@ -76,21 +106,21 @@ namespace mln
p_edges_psite<G, F>::p_edges_psite()
{
}
-
+
template <typename G, typename F>
inline
p_edges_psite<G, F>::p_edges_psite(const p_edges<G,F>& s)
: super_(s)
{
}
-
+
template <typename G, typename F>
inline
p_edges_psite<G, F>::p_edges_psite(const p_edges<G,F>& s, unsigned id)
: super_(s, id)
{
}
-
+
template <typename G, typename F>
inline
const util::edge<G>&
@@ -99,6 +129,62 @@ namespace mln
return this->elt_;
}
+ template <typename G, typename F>
+ inline
+ util::vertex<G>
+ p_edges_psite<G, F>::v1() const
+ {
+ return this->elt_.graph().vertex(this->elt_.v1());
+ }
+
+ template <typename G, typename F>
+ inline
+ util::vertex<G>
+ p_edges_psite<G, F>::v2() const
+ {
+ return this->elt_.graph().vertex(this->elt_.v2());
+ }
+
+
+ namespace internal
+ {
+
+ /// subject_impl (Proxy)
+
+ template <typename G, typename F, typename E>
+ inline
+ const E&
+ subject_impl< const p_edges_psite<G,F>&, E >::exact_() const
+ {
+ return internal::force_exact<const E>(*this);
+ }
+
+ template <typename G, typename F, typename E>
+ inline
+ const util::edge<G>&
+ subject_impl< const p_edges_psite<G,F>&, E >::e() const
+ {
+ return exact_().get_subject().e();
+ }
+
+ template <typename G, typename F, typename E>
+ inline
+ util::vertex<G>
+ subject_impl< const p_edges_psite<G,F>&, E >::v1() const
+ {
+ return exact_().get_subject().v1();
+ }
+
+ template <typename G, typename F, typename E>
+ inline
+ util::vertex<G>
+ subject_impl< const p_edges_psite<G,F>&, E >::v2() const
+ {
+ return exact_().get_subject().v2();
+ }
+
+ } // end of namespace mln::internal
+
# endif // ! MLN_INCLUDE_ONLY
} // end of namespace mln
diff --git a/milena/mln/core/site_set/p_vertices.hh b/milena/mln/core/site_set/p_vertices.hh
index adbe55d..0ebab63 100644
--- a/milena/mln/core/site_set/p_vertices.hh
+++ b/milena/mln/core/site_set/p_vertices.hh
@@ -145,9 +145,9 @@ namespace mln
/// Return the value associated to an element of this site set.
/// \{
- const mln_result(F)& operator()(const psite& p) const;
- const mln_result(F)& operator()(const util::vertex<G>& p) const;
- const mln_result(F)& operator()(unsigned id_v) const;
+ mln_result(F) operator()(const psite& p) const;
+ mln_result(F) operator()(const util::vertex<G>& p) const;
+ mln_result(F) operator()(unsigned id_v) const;
/// \}
/// Accessors.
@@ -159,7 +159,7 @@ namespace mln
/// \}
private:
- const G* g_;
+ G g_;
F f_;
};
@@ -202,7 +202,7 @@ namespace mln
template <typename G, typename F>
inline
p_vertices<G,F>::p_vertices(const G& g, const F& f)
- : g_ (&g), f_(f)
+ : g_ (g), f_(f)
{
}
@@ -219,7 +219,7 @@ namespace mln
unsigned
p_vertices<G,F>::nvertices() const
{
- return this->g_->v_nmax();
+ return this->g_.v_nmax();
}
template <typename G, typename F>
@@ -227,7 +227,7 @@ namespace mln
bool
p_vertices<G,F>::is_valid() const
{
- return g_ != 0;
+ return true; /* FIXME: g_.is_valid() */;
}
template <typename G, typename F>
@@ -235,7 +235,7 @@ namespace mln
void
p_vertices<G,F>::invalidate()
{
- g_ = 0;
+ /* FIXME: g_.invalidate() ;*/
}
template <typename G, typename F>
@@ -256,7 +256,7 @@ namespace mln
mln_precondition(is_valid());
return
// Check whether P is compatible with this psite set.
- (p.graph() == *g_) &&
+ (p.graph() == g_) &&
// Check that the vertex id of P belongs to the range of valid
// vertex ids.
(p.is_valid());
@@ -274,7 +274,7 @@ namespace mln
template <typename G, typename F>
inline
- const mln_result(F)&
+ mln_result(F)
p_vertices<G,F>::operator()(const psite& p) const
{
mln_precondition(g_.has(p.v()));
@@ -283,19 +283,19 @@ namespace mln
template <typename G, typename F>
inline
- const mln_result(F)&
+ mln_result(F)
p_vertices<G,F>::operator()(const util::vertex<G>& v) const
{
- mln_precondition(g_->has_v(v));
+ mln_precondition(g_.has_v(v));
return (*this)(v.id());
}
template <typename G, typename F>
inline
- const mln_result(F)&
+ mln_result(F)
p_vertices<G,F>::operator()(unsigned id_v) const
{
- mln_precondition(g_->has_v(id_v));
+ mln_precondition(g_.has_v(id_v));
return f_(id_v);
}
@@ -305,7 +305,7 @@ namespace mln
p_vertices<G,F>::graph() const
{
mln_precondition(is_valid());
- return *g_;
+ return g_;
}
template <typename G, typename F>
@@ -320,7 +320,7 @@ namespace mln
bool
operator==(const p_vertices<G,F>& lhs, const p_vertices<G,F>& rhs)
{
- return (*lhs.g_) == (*rhs.g_);
+ return (lhs.g_) == (rhs.g_);
}
template <typename G, typename F>
diff --git a/milena/mln/core/site_set/p_vertices_psite.hh b/milena/mln/core/site_set/p_vertices_psite.hh
index 5a5da0d..883eb5c 100644
--- a/milena/mln/core/site_set/p_vertices_psite.hh
+++ b/milena/mln/core/site_set/p_vertices_psite.hh
@@ -42,12 +42,11 @@ namespace mln
// Forward declaration.
template <typename G, typename F> class p_vertices;
-
+ namespace internal { template <typename Subject, typename E> struct subject_impl; }
template <typename G, typename F>
class p_vertices_psite :
-
public internal::graph_psite_base< p_vertices<G,F>, p_vertices_psite<G,F> >
{
typedef p_vertices_psite<G,F> self_;
@@ -63,6 +62,31 @@ namespace mln
};
+ namespace internal
+ {
+
+ /// Subject_impl (Proxy)
+
+ template <typename G, typename F, typename E>
+ struct subject_impl< const p_vertices_psite<G,F>&, E >
+ : subject_impl< const graph_psite_base< p_vertices<G,F>,
+ p_vertices_psite<G,F> >&, E >
+ {
+ const util::vertex<G>& v() const;
+
+ private:
+ const E& exact_() const;
+ };
+
+ template <typename G, typename F, typename E>
+ struct subject_impl< p_vertices_psite<G,F>&, E >
+ : subject_impl< const p_vertices_psite<G,F>&, E >,
+ subject_impl< graph_psite_base< p_vertices<G,F>,
+ p_vertices_psite<G,F> >&, E >
+ {
+ };
+
+ } // end of namespace mln::internal
# ifndef MLN_INCLUDE_ONLY
@@ -94,6 +118,30 @@ namespace mln
return this->elt_;
}
+
+ namespace internal
+ {
+
+ /// subject_impl (Proxy)
+
+ template <typename G, typename F, typename E>
+ inline
+ const E&
+ subject_impl< const p_vertices_psite<G,F>&, E >::exact_() const
+ {
+ return internal::force_exact<const E>(*this);
+ }
+
+ template <typename G, typename F, typename E>
+ inline
+ const util::vertex<G>&
+ subject_impl< const p_vertices_psite<G,F>&, E >::v() const
+ {
+ return exact_().get_subject().v();
+ }
+
+ } // end of namespace mln::internal
+
# endif // ! MLN_INCLUDE_ONLY
} // end of namespace mln
diff --git a/milena/mln/debug/draw_graph.hh b/milena/mln/debug/draw_graph.hh
index 114f57b..abc96a4 100644
--- a/milena/mln/debug/draw_graph.hh
+++ b/milena/mln/debug/draw_graph.hh
@@ -88,6 +88,30 @@ namespace mln
inline
void
draw_graph(Image<I>& ima,
+ const p_edges<G, F>& pe,
+ mln_value(I) vertex_v,
+ mln_value(I) edge_v)
+ {
+ // Draw edges.
+ typedef p_edges<G, F> pe_t;
+ mln_piter(pe_t) p(pe);
+ for_all(p)
+ {
+ if (exact(ima).has(p.first()) && exact(ima).has(p.second()))
+ draw::line(exact(ima), p.first(), p.second(), edge_v);
+ if (exact(ima).has(p.first()))
+ exact(ima)(p.first()) = vertex_v;
+ if (exact(ima).has(p.second()))
+ exact(ima)(p.second()) = vertex_v;
+ }
+
+ }
+
+
+ template <typename I, typename G, typename F>
+ inline
+ void
+ draw_graph(Image<I>& ima,
const p_vertices<G, F>& pv,
mln_value(I) vertex_v,
mln_value(I) edge_v)
diff --git a/milena/mln/util/edge.hh b/milena/mln/util/edge.hh
index 57d4e49..e98370b 100644
--- a/milena/mln/util/edge.hh
+++ b/milena/mln/util/edge.hh
@@ -76,6 +76,9 @@ namespace mln
/// Set id_ with \p id;
void update_id(unsigned id);
+ /// Conversion to the edge id.
+ operator unsigned() const;
+
/// Return a reference to the graph holding this edge.
const G& graph() const;
@@ -219,6 +222,13 @@ namespace mln
template <typename G>
inline
+ edge<G>::operator unsigned() const
+ {
+ return id_;
+ }
+
+ template <typename G>
+ inline
const G&
edge<G>::graph() const
{
diff --git a/milena/mln/util/internal/graph_iter.hh b/milena/mln/util/internal/graph_iter.hh
index 1e89c5c..6da2e3c 100644
--- a/milena/mln/util/internal/graph_iter.hh
+++ b/milena/mln/util/internal/graph_iter.hh
@@ -68,7 +68,6 @@ namespace mln
/// Called in next();
unsigned next_id_() const;
- using super_::p_;
friend class graph_iter_base<G, util::vertex<G>, vertex_fwd_iterator<G> >;
};
@@ -97,7 +96,6 @@ namespace mln
/// Called in next();
unsigned next_id_() const;
- using super_::p_;
friend class graph_iter_base<G, util::vertex<G>, vertex_bkd_iterator<G> >;
};
@@ -126,7 +124,6 @@ namespace mln
/// Called in next();
unsigned next_id_() const;
- using super_::p_;
friend class graph_iter_base<G, util::edge<G>, edge_fwd_iterator<G> >;
};
@@ -155,7 +152,6 @@ namespace mln
/// Called in next();
unsigned next_id_() const;
- using super_::p_;
friend class graph_iter_base<G, util::edge<G>, edge_bkd_iterator<G> >;
};
@@ -195,7 +191,7 @@ namespace mln
unsigned
vertex_fwd_iterator<G>::next_id_() const
{
- return p_.id() + 1;
+ return this->p_.id() + 1;
}
@@ -222,7 +218,7 @@ namespace mln
unsigned
vertex_bkd_iterator<G>::start_id_() const
{
- return p_.graph().v_nmax() - 1;
+ return this->p_.graph().v_nmax() - 1;
}
template <typename G>
@@ -230,7 +226,7 @@ namespace mln
unsigned
vertex_bkd_iterator<G>::next_id_() const
{
- return p_.id() - 1;
+ return this->p_.id() - 1;
}
@@ -265,7 +261,7 @@ namespace mln
unsigned
edge_fwd_iterator<G>::next_id_() const
{
- return p_.id() + 1;
+ return this->p_.id() + 1;
}
@@ -292,7 +288,7 @@ namespace mln
unsigned
edge_bkd_iterator<G>::start_id_() const
{
- return p_.graph().e_nmax() - 1;
+ return this->p_.graph().e_nmax() - 1;
}
template <typename G>
@@ -300,7 +296,7 @@ namespace mln
unsigned
edge_bkd_iterator<G>::next_id_() const
{
- return p_.id() - 1;
+ return this->p_.id() - 1;
}
# endif // ! MLN_INCLUDE_ONLY
diff --git a/milena/mln/util/internal/graph_iter_base.hh b/milena/mln/util/internal/graph_iter_base.hh
index cad716e..10cbe64 100644
--- a/milena/mln/util/internal/graph_iter_base.hh
+++ b/milena/mln/util/internal/graph_iter_base.hh
@@ -69,11 +69,17 @@ namespace mln
/// Conversion operator. Returns the element id.
operator unsigned() const;
+
+ /// Conversion operator. Returns the graph element.
+ operator const Elt&() const;
/// \}
/// Proxy subject
const Elt& subj_();
+ /// Return the element pointed by this iterator.
+ const Elt& p_hook_() const;
+
protected:
graph_iter_base(const G& g);
@@ -143,12 +149,27 @@ namespace mln
template <typename G, typename Elt, typename E>
inline
+ graph_iter_base<G, Elt, E>::operator const Elt&() const
+ {
+ return p_;
+ }
+
+ template <typename G, typename Elt, typename E>
+ inline
const Elt&
graph_iter_base<G, Elt, E>::subj_()
{
return p_;
}
+ template <typename G, typename Elt, typename E>
+ inline
+ const Elt&
+ graph_iter_base<G, Elt, E>::p_hook_() const
+ {
+ return p_;
+ }
+
# endif // ! MLN_INCLUDE_ONLY
} // end of namespace mln::internal
diff --git a/milena/mln/util/internal/graph_nbh_iter.hh b/milena/mln/util/internal/graph_nbh_iter.hh
index d06a008..b99de7b 100644
--- a/milena/mln/util/internal/graph_nbh_iter.hh
+++ b/milena/mln/util/internal/graph_nbh_iter.hh
@@ -331,7 +331,7 @@ namespace mln
void
vertex_nbh_vertex_fwd_iterator<G>::update_()
{
- this->p_.update_id(this->c_->ith_nbh_vertex(this->i_));
+ this->elt_.update_id(this->c_->ith_nbh_vertex(this->i_));
}
/*-------------------------------`
@@ -381,7 +381,7 @@ namespace mln
void
vertex_nbh_vertex_bkd_iterator<G>::update_()
{
- this->p_.update_id(this->c_->ith_nbh_vertex(this->i_));
+ this->elt_.update_id(this->c_->ith_nbh_vertex(this->i_));
}
@@ -432,7 +432,7 @@ namespace mln
void
vertex_nbh_edge_fwd_iterator<G>::update_()
{
- this->p_.update_id(this->c_->ith_nbh_edge(this->i_));
+ this->elt_.update_id(this->c_->ith_nbh_edge(this->i_));
}
/*-----------------------------`
@@ -482,7 +482,7 @@ namespace mln
void
vertex_nbh_edge_bkd_iterator<G>::update_()
{
- this->p_.update_id(this->c_->ith_nbh_edge(this->i_));
+ this->elt_.update_id(this->c_->ith_nbh_edge(this->i_));
}
@@ -545,7 +545,7 @@ namespace mln
e_id = this->c_->ith_nbh_edge(this->i_);
}
- this->p_.update_id(e_id);
+ this->elt_.update_id(e_id);
}
/*-----------------------------`
@@ -605,7 +605,7 @@ namespace mln
e_id = this->c_->ith_nbh_edge(this->i_);
}
- this->p_.update_id(e_id);
+ this->elt_.update_id(e_id);
}
# endif // !MLN_INCLUDE_ONLY
diff --git a/milena/mln/util/internal/graph_nbh_iter_base.hh b/milena/mln/util/internal/graph_nbh_iter_base.hh
index a28be8b..2654055 100644
--- a/milena/mln/util/internal/graph_nbh_iter_base.hh
+++ b/milena/mln/util/internal/graph_nbh_iter_base.hh
@@ -31,18 +31,22 @@
# include <mln/core/concept/proxy.hh>
/// \file mln/util/internal/graph_nbh_iter_base.hh
+///
/// Base implementation for graph edge and vertex neighborhood iterator.
namespace mln
{
+ // Forward declaration.
+ template <typename S> class p_indexed_psite;
+
namespace internal
{
- template <typename G, typename C, typename P, typename E>
+ template <typename G, typename C, typename Elt, typename E>
class nbh_iterator_base
: public Proxy< E >,
- public internal::proxy_impl< const P&, E >
+ public internal::proxy_impl< const Elt&, E >
{
public:
@@ -65,16 +69,28 @@ namespace mln
/// Conversion operator. Returns the element ID.
operator unsigned() const;
+ /// The psite around which this iterator moves.
+ const C& center() const;
+
/// Make \p c the center of this iterator.
+ template <typename S>
+ void center_at(const p_indexed_psite<S>& c);
+
template <typename C2>
void center_at(const C2& c);
+ /// Change the graph targeted by this iterator.
+ void change_target(const G& g);
+
+ /// Hook to the current location.
+ const Elt& elt_hook_() const;
+
/// \}
/// Proxy.
/// \{
/// Proxy subject
- const P& subj_();
+ const Elt& subj_();
/// \}
protected:
@@ -86,58 +102,58 @@ namespace mln
/// \}
const C* c_; // Center
- P p_;
+ Elt elt_;
unsigned i_;
};
# ifndef MLN_INCLUDE_ONLY
- template <typename G, typename C, typename P, typename E>
+ template <typename G, typename C, typename Elt, typename E>
inline
- nbh_iterator_base<G, C, P, E>::nbh_iterator_base()
+ nbh_iterator_base<G,C,Elt,E>::nbh_iterator_base()
{
}
- template <typename G, typename C, typename P, typename E>
+ template <typename G, typename C, typename Elt, typename E>
template <typename C2>
inline
- nbh_iterator_base<G, C, P, E>::nbh_iterator_base(const C2& c)
- : p_(c.graph()), i_(0)
+ nbh_iterator_base<G,C,Elt,E>::nbh_iterator_base(const C2& c)
+ : elt_(c.graph()), i_(0)
{
//FIXME: Check if typeof(c.graph()) == G
center_at(c);
}
- template <typename G, typename C, typename P, typename E>
+ template <typename G, typename C, typename Elt, typename E>
inline
bool
- nbh_iterator_base<G, C, P, E>::is_valid() const
+ nbh_iterator_base<G,C,Elt,E>::is_valid() const
{
return exact(this)->is_valid_();
}
- template <typename G, typename C, typename P, typename E>
+ template <typename G, typename C, typename Elt, typename E>
inline
void
- nbh_iterator_base<G, C, P, E>::invalidate()
+ nbh_iterator_base<G,C,Elt,E>::invalidate()
{
i_ = mln_max(unsigned);
}
- template <typename G, typename C, typename P, typename E>
+ template <typename G, typename C, typename Elt, typename E>
inline
void
- nbh_iterator_base<G, C, P, E>::start()
+ nbh_iterator_base<G,C,Elt,E>::start()
{
i_ = exact(this)->start_id_();
if (is_valid())
exact(this)->update_();
}
- template <typename G, typename C, typename P, typename E>
+ template <typename G, typename C, typename Elt, typename E>
inline
void
- nbh_iterator_base<G, C, P, E>::next()
+ nbh_iterator_base<G,C,Elt,E>::next()
{
mln_precondition(is_valid());
mln_precondition(c_->is_valid());
@@ -147,42 +163,89 @@ namespace mln
exact(this)->update_();
}
- template <typename G, typename C, typename P, typename E>
+ template <typename G, typename C, typename Elt, typename E>
inline
unsigned
- nbh_iterator_base<G, C, P, E>::index() const
+ nbh_iterator_base<G,C,Elt,E>::index() const
{
return i_;
}
- template <typename G, typename C, typename P, typename E>
+ template <typename G, typename C, typename Elt, typename E>
+ inline
+ nbh_iterator_base<G,C,Elt,E>::operator unsigned() const
+ {
+ return elt_.id();
+ }
+
+ template <typename G, typename C, typename Elt, typename E>
inline
- nbh_iterator_base<G, C, P, E>::operator unsigned() const
+ const C&
+ nbh_iterator_base<G,C,Elt,E>::center() const
{
- return p_.id();
+ mln_precondition(c_ != 0);
+ return *c_;
}
- template <typename G, typename C, typename P, typename E>
+ template <typename G, typename C, typename Elt, typename E>
inline
- const P&
- nbh_iterator_base<G, C, P, E>::subj_()
+ const Elt&
+ nbh_iterator_base<G,C,Elt,E>::subj_()
{
- return p_;
+ return elt_;
}
- template <typename G, typename C, typename P, typename E>
+ template <typename G, typename C, typename Elt, typename E>
+ template <typename S>
+ inline
+ void
+ nbh_iterator_base<G,C,Elt,E>::center_at(const p_indexed_psite<S>& c)
+ {
+ //FIXME: p_indexed_psite does not have a conversion operator towards a
+ // p_edges/vertices_psite or a vertex/edge.
+ c_ = & static_cast< const C& >(c.unproxy_());
+
+ //FIXME: c_->graph() may not be the right graph!
+ // The target may not be initialized before this call...
+ // See core/neighb.hh in center_at(), i.center_at().
+ elt_.change_graph(c_->graph());
+
+ invalidate();
+ }
+
+ template <typename G, typename C, typename Elt, typename E>
template <typename C2>
inline
void
- nbh_iterator_base<G, C, P, E>::center_at(const C2& c)
+ nbh_iterator_base<G,C,Elt,E>::center_at(const C2& c)
{
- internal::get_adr(c_, c);
- mln_postcondition(c_ != 0);
- p_.change_graph(c.graph());
+ mlc_converts_to(C2, const C&)::check();
+ c_ = & static_cast< const C& >(exact(c));
+
+ //FIXME: c_->graph() may not be the right graph!
+ // The target may not be initialized before this call...
+ // See core/neighb.hh in center_at(), i.center_at().
+ elt_.change_graph(c_->graph());
invalidate();
}
+ template <typename G, typename C, typename Elt, typename E>
+ inline
+ void
+ nbh_iterator_base<G,C,Elt,E>::change_target(const G& g)
+ {
+ elt_.change_graph(g);
+ }
+
+ template <typename G, typename C, typename Elt, typename E>
+ inline
+ const Elt&
+ nbh_iterator_base<G,C,Elt,E>::elt_hook_() const
+ {
+ return elt_;
+ }
+
# endif // !MLN_INCLUDE_ONLY
} // End of namespace mln::internal
diff --git a/milena/mln/util/vertex.hh b/milena/mln/util/vertex.hh
index 197dcab..fcb6f5b 100644
--- a/milena/mln/util/vertex.hh
+++ b/milena/mln/util/vertex.hh
@@ -94,6 +94,9 @@ namespace mln
/// Returns the vertex id.
unsigned id() const;
+ /// Conversion to the vertex id.
+ operator unsigned() const;
+
protected:
G g_;
unsigned id_;
@@ -292,6 +295,13 @@ namespace mln
return id_;
}
+ template<typename G>
+ inline
+ vertex<G>::operator unsigned() const
+ {
+ return id_;
+ }
+
template <typename G>
inline
--
1.5.6.5
1
0
* mln/accu/count_adjacent_vertices.hh: add missing is_valid().
* mln/canvas/labeling.hh: cleanup.
* mln/labeling/relabel.hh,
* mln/convert/from_to.hh: reorder declarations.
* mln/linear/gaussian.hh,
* mln/core/site_set/p_vaccess.hh,
* mln/core/alias/complex_geometry.hh: add missing includes.
* mln/registration/registration.hh,
* mln/pw/cst.hh,
* mln/pw/value.hh,
* mln/geom/ninds.hh,
* mln/fun/p2b/chess.hh,
* mln/core/image/complex_neighborhood_piter.hh
* mln/core/dpsites_piter.hh: update comments.
* mln/win/multiple_size.hh,
* mln/core/image/complex_window_piter.hh: add center_at_().
* mln/core/image/image_if.hh: move init_() implementation between
MLN_INCLUDE_ONLY guards.
* mln/core/internal/graph_psite_base.hh: be sure to not return a
temporary object. The psite holds a site.
* mln/core/routine/duplicate.hh: rename guards.
* mln/fun/i2v/array.hh
* mln/fun/internal/array_base.hh
* mln/fun/l2l/relabel.hh: make array and relabel inherit from the
proper function concept. The mutable result must be typedef-ed again
in that classes.
* mln/morpho/opening_area_on_vertices.hh: fix wrong prototype.
* mln/registration/get_rot.hh: get rid of warnings.
* mln/util/ord_pair.hh: add default constructor.
* mln/util/site_pair.hh: add accessors.
* tests/unit_test/Makefile.am,
* tests/unit_test/mln_geom_resize.cc: update unit tests.
* headers.mk: remove geom/resize.hh from distribution.
---
milena/ChangeLog | 55 +++++++-
milena/headers.mk | 1 -
milena/mln/accu/count_adjacent_vertices.hh | 11 ++
milena/mln/canvas/labeling.hh | 8 +-
milena/mln/convert/from_to.hh | 31 ++--
milena/mln/core/alias/complex_geometry.hh | 1 +
milena/mln/core/dpsites_piter.hh | 2 +-
.../mln/core/image/complex_neighborhood_piter.hh | 2 +-
milena/mln/core/image/complex_window_piter.hh | 22 +--
milena/mln/core/image/image_if.hh | 38 +++---
milena/mln/core/internal/graph_psite_base.hh | 158 +++++++++++++++++++-
milena/mln/core/routine/duplicate.hh | 31 ++--
milena/mln/core/site_set/p_vaccess.hh | 11 +-
milena/mln/fun/i2v/array.hh | 9 +-
milena/mln/fun/internal/array_base.hh | 53 ++++----
milena/mln/fun/l2l/relabel.hh | 9 +-
milena/mln/fun/p2b/chess.hh | 10 +-
milena/mln/geom/ninds.hh | 10 +-
milena/mln/labeling/relabel.hh | 33 ++--
milena/mln/linear/gaussian.hh | 6 +-
milena/mln/morpho/opening_area_on_vertices.hh | 2 +-
milena/mln/pw/cst.hh | 8 +-
milena/mln/pw/value.hh | 27 ++--
milena/mln/registration/get_rot.hh | 5 +
milena/mln/registration/registration.hh | 10 +-
milena/mln/util/ord_pair.hh | 18 ++-
milena/mln/util/site_pair.hh | 107 ++++++++++++-
milena/mln/win/multiple_size.hh | 14 ++-
milena/tests/unit_test/Makefile.am | 2 -
milena/tests/unit_test/mln_geom_resize.cc | 11 --
30 files changed, 508 insertions(+), 197 deletions(-)
delete mode 100644 milena/tests/unit_test/mln_geom_resize.cc
diff --git a/milena/ChangeLog b/milena/ChangeLog
index f5bebd3..4d6d70f 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,4 +1,57 @@
-2008-12-30 Guillaume Lazzara <z(a)lrde.epita.fr>
+2008-12-31 Guillaume Lazzara <z(a)lrde.epita.fr>
+
+ Various small fixes.
+
+ * mln/accu/count_adjacent_vertices.hh: add missing is_valid().
+
+ * mln/canvas/labeling.hh: cleanup.
+
+ * mln/labeling/relabel.hh,
+ * mln/convert/from_to.hh: reorder declarations.
+
+ * mln/linear/gaussian.hh,
+ * mln/core/site_set/p_vaccess.hh,
+ * mln/core/alias/complex_geometry.hh: add missing includes.
+
+ * mln/registration/registration.hh,
+ * mln/pw/cst.hh,
+ * mln/pw/value.hh,
+ * mln/geom/ninds.hh,
+ * mln/fun/p2b/chess.hh,
+ * mln/core/image/complex_neighborhood_piter.hh
+ * mln/core/dpsites_piter.hh: update comments.
+
+ * mln/win/multiple_size.hh,
+ * mln/core/image/complex_window_piter.hh: add center_at_().
+
+ * mln/core/image/image_if.hh: move init_() implementation between
+ MLN_INCLUDE_ONLY guards.
+
+ * mln/core/internal/graph_psite_base.hh: be sure to not return a
+ temporary object. The psite holds a site.
+
+ * mln/core/routine/duplicate.hh: rename guards.
+
+ * mln/fun/i2v/array.hh
+ * mln/fun/internal/array_base.hh
+ * mln/fun/l2l/relabel.hh: make array and relabel inherit from the
+ proper function concept. The mutable result must be typedef-ed again
+ in that classes.
+
+ * mln/morpho/opening_area_on_vertices.hh: fix wrong prototype.
+
+ * mln/registration/get_rot.hh: get rid of warnings.
+
+ * mln/util/ord_pair.hh: add default constructor.
+
+ * mln/util/site_pair.hh: add accessors.
+
+ * tests/unit_test/Makefile.am,
+ * tests/unit_test/mln_geom_resize.cc: update unit tests.
+
+ * mln/accu/count_adjacent_vertices.hh: add missing is_valid().
+
+2008-12-31 Guillaume Lazzara <z(a)lrde.epita.fr>
Rename mln_sum_x to mln_sum_product.
diff --git a/milena/headers.mk b/milena/headers.mk
index faea509..8cd49e1 100644
--- a/milena/headers.mk
+++ b/milena/headers.mk
@@ -21,7 +21,6 @@ mln/geom/size3d.hh \
mln/geom/ninds.hh \
mln/geom/nslis.hh \
mln/geom/delta.hh \
-mln/geom/resize.hh \
mln/geom/nsites.hh \
mln/geom/min_col.hh \
mln/geom/complex_geometry.hh \
diff --git a/milena/mln/accu/count_adjacent_vertices.hh b/milena/mln/accu/count_adjacent_vertices.hh
index 382e509..9d1f7b3 100644
--- a/milena/mln/accu/count_adjacent_vertices.hh
+++ b/milena/mln/accu/count_adjacent_vertices.hh
@@ -76,6 +76,9 @@ namespace mln
/// Get the value of the accumulator.
unsigned to_result() const;
+ /// Return whether this accu can return a result.
+ bool is_valid() const;
+
protected:
/// Update the value of the counter.
void update_ ();
@@ -168,6 +171,14 @@ namespace mln
count__ = vertices_.size();
}
+ template <typename F, typename S>
+ inline
+ bool
+ count_adjacent_vertices<F,S>::is_valid() const
+ {
+ return true;
+ }
+
# endif // ! MLN_INCLUDE_ONLY
} // end of namespace mln::accu
diff --git a/milena/mln/canvas/labeling.hh b/milena/mln/canvas/labeling.hh
index 6702ee0..fb539f7 100644
--- a/milena/mln/canvas/labeling.hh
+++ b/milena/mln/canvas/labeling.hh
@@ -196,7 +196,7 @@ namespace mln
trace::exiting("canvas::impl::generic::labeling");
return output;
}
-
+
} // end of namespace mln::canvas::impl::generic
} // end of namespace mln::canvas::impl
@@ -385,12 +385,12 @@ namespace mln
F& functor, L& nlabels)
{
trace::entering("canvas::labeling");
-
+
internal::labeling_tests(input, nbh, functor, nlabels);
-
+
mln_ch_value(I, L) output;
output = internal::labeling_dispatch(input, nbh, functor, nlabels);
-
+
trace::exiting("canvas::labeling");
return output;
}
diff --git a/milena/mln/convert/from_to.hh b/milena/mln/convert/from_to.hh
index 8e3510a..e86e73a 100644
--- a/milena/mln/convert/from_to.hh
+++ b/milena/mln/convert/from_to.hh
@@ -67,22 +67,6 @@ namespace mln
namespace internal
{
-
- // Default dispatch if the two arguments are objects.
-
- // Object -> Object
- template <typename F, typename T>
- inline
- void
- from_to_dispatch(const Object<F>& from, Object<T>& to)
- {
- typedef mlc_converts_to(F, T) F_converts_to_T;
- internal::from_to_dispatch(F_converts_to_T(),
- exact(from), exact(to));
- }
-
-
-
// Dispatch to specific implementation.
// Image -> Site_Set.
@@ -133,6 +117,21 @@ namespace mln
+ // Default dispatch if the two arguments are objects.
+
+ // Object -> Object
+ template <typename F, typename T>
+ inline
+ void
+ from_to_dispatch(const Object<F>& from, Object<T>& to)
+ {
+ typedef mlc_converts_to(F, T) F_converts_to_T;
+ internal::from_to_dispatch(F_converts_to_T(),
+ exact(from), exact(to));
+ }
+
+
+
// Dispatch entry points.
// Check whether arguments are an object or not.
diff --git a/milena/mln/core/alias/complex_geometry.hh b/milena/mln/core/alias/complex_geometry.hh
index 44fa899..2ba0362 100644
--- a/milena/mln/core/alias/complex_geometry.hh
+++ b/milena/mln/core/alias/complex_geometry.hh
@@ -33,6 +33,7 @@
/// Definition of mln::geom::complex_geometry aliases.
# include <mln/geom/complex_geometry.hh>
+# include <mln/core/alias/point2d.hh>
# include <mln/core/alias/point3df.hh>
diff --git a/milena/mln/core/dpsites_piter.hh b/milena/mln/core/dpsites_piter.hh
index 6895cba..91709d7 100644
--- a/milena/mln/core/dpsites_piter.hh
+++ b/milena/mln/core/dpsites_piter.hh
@@ -120,7 +120,7 @@ namespace mln
/// Go to the next point.
void do_next_();
- /// Set the reference psite.
+ /// Do some work while setting the reference site.
template <typename Pref>
void center_at_(const Pref&);
diff --git a/milena/mln/core/image/complex_neighborhood_piter.hh b/milena/mln/core/image/complex_neighborhood_piter.hh
index f69455c..f57588b 100644
--- a/milena/mln/core/image/complex_neighborhood_piter.hh
+++ b/milena/mln/core/image/complex_neighborhood_piter.hh
@@ -153,7 +153,7 @@ namespace mln
/// Go to the next site.
void do_next_();
- /// Set the reference psite.
+ /// Do some work while setting the reference site.
template <typename Pref>
void center_at_(const Pref&);
diff --git a/milena/mln/core/image/complex_window_piter.hh b/milena/mln/core/image/complex_window_piter.hh
index 4a77fbc..72952d5 100644
--- a/milena/mln/core/image/complex_window_piter.hh
+++ b/milena/mln/core/image/complex_window_piter.hh
@@ -86,12 +86,10 @@ namespace mln
/// Go to the next site.
void do_next_();
- /// Set the reference psite.
- /* FIXME: Careful, this method overrides the (non virtual) method
- internal::site_relative_iterator_base<S, E>::center_at. See
- FIXME above. */
+ /// Do some work while setting the reference site.
template <typename Pref>
- void center_at(const Pref& c);
+ void center_at_(const Pref& c);
+
/// Compute the current psite.
psite compute_p_() const;
/// \}
@@ -154,12 +152,10 @@ namespace mln
/// Go to the next site.
void do_next_();
- /// Set the reference psite.
- /* FIXME: Careful, this method overrides the (non virtual) method
- internal::site_relative_iterator_base<S, E>::center_at. See
- FIXME above. */
+ /// Do some work while setting the reference site.
template <typename Pref>
- void center_at(const Pref& c);
+ void center_at_(const Pref& c);
+
/// Compute the current psite.
psite compute_p_() const;
/// \}
@@ -243,9 +239,8 @@ namespace mln
template <typename Pref>
inline
void
- complex_window_fwd_piter<I, G, W>::center_at(const Pref& c)
+ complex_window_fwd_piter<I, G, W>::center_at_(const Pref&)
{
- super_::center_at(c);
iter_.center_at(this->center().face());
}
@@ -341,9 +336,8 @@ namespace mln
template <typename Pref>
inline
void
- complex_window_bkd_piter<I, G, W>::center_at(const Pref& c)
+ complex_window_bkd_piter<I, G, W>::center_at_(const Pref& c)
{
- super_::center_at(c);
iter_.center_at(this->center().face());
}
diff --git a/milena/mln/core/image/image_if.hh b/milena/mln/core/image/image_if.hh
index 168a7bc..ce07f35 100644
--- a/milena/mln/core/image/image_if.hh
+++ b/milena/mln/core/image/image_if.hh
@@ -115,26 +115,6 @@ namespace mln
operator image_if<const I, F>() const;
};
-
- // init_.
-
- template <typename I, typename F>
- void init_(tag::function_t, F& f, const image_if<I,F>& model)
- {
- f = model.domain().predicate();
- }
-
- template <typename I, typename F, typename J>
- void init_(tag::image_t, image_if<I,F>& target, const J& model)
- {
- I ima;
- init_(tag::image, ima, exact(model));
- F f;
- init_(tag::function, f, exact(model));
- target.init_(ima, f);
- }
-
-
// Operators.
// Image | Function_p2b.
@@ -165,6 +145,24 @@ namespace mln
# ifndef MLN_INCLUDE_ONLY
+ // init_.
+
+ template <typename I, typename F>
+ void init_(tag::function_t, F& f, const image_if<I,F>& model)
+ {
+ f = model.domain().predicate();
+ }
+
+ template <typename I, typename F, typename J>
+ void init_(tag::image_t, image_if<I,F>& target, const J& model)
+ {
+ I ima;
+ init_(tag::image, ima, exact(model));
+ F f;
+ init_(tag::function, f, exact(model));
+ target.init_(ima, f);
+ }
+
// internal::data< image_if<I,F> >
namespace internal
diff --git a/milena/mln/core/internal/graph_psite_base.hh b/milena/mln/core/internal/graph_psite_base.hh
index cbff5f0..d0df650 100644
--- a/milena/mln/core/internal/graph_psite_base.hh
+++ b/milena/mln/core/internal/graph_psite_base.hh
@@ -100,7 +100,7 @@ namespace mln
const typename S::graph_element& element() const;
/// Return the underlying element.
- const typename S::graph_element& hook_elt_() const;
+ const typename S::graph_element& p_hook_() const;
protected:
@@ -118,6 +118,7 @@ namespace mln
/// \}
const S* s_;
+ mln_site(S) site_;
typename S::graph_element elt_;
};
@@ -155,6 +156,39 @@ namespace mln
/// \}
+ /// \{
+ /// subject_impl specialization (Proxy)
+ template <typename S, typename P, typename E>
+ struct subject_impl< const graph_psite_base<S,P>&, E >
+ {
+ const S* target_() const;
+ const S& site_set() const;
+ const typename S::graph_t& graph() const;
+ unsigned id() const;
+ bool is_valid() const;
+ operator unsigned() const;
+ operator const typename S::graph_element&() const;
+ const typename S::graph_element& element() const;
+ const typename S::graph_element& p_hook_() const;
+
+ private:
+ const E& exact_() const;
+ };
+
+ template <typename S, typename P, typename E>
+ struct subject_impl< graph_psite_base<S,P>&, E > :
+ subject_impl< const graph_psite_base<S,P>&, E >
+ {
+ void change_target(const S& new_target);
+ void update_id(unsigned elt_id);
+ void invalidate();
+
+ private:
+ E& exact_();
+ };
+ /// \}
+
+
# ifndef MLN_INCLUDE_ONLY
@@ -195,7 +229,9 @@ namespace mln
void
graph_psite_base<S,E>::update_id(unsigned id)
{
+ mln_precondition(s_ != 0);
elt_.update_id(id);
+ site_ = s_->function()(elt_.id());
}
template <typename S, typename E>
@@ -254,8 +290,12 @@ namespace mln
const mln_site(S)&
graph_psite_base<S,E>::subj_()
{
- mln_precondition(s_ != 0);
- return s_->function()(elt_.id());
+ /*FIXME: we may like to enable the following precondition, however, we
+ ** can't do that since neighb_*_niters update the psite target after having
+ ** taken the adress of the subject.
+ */
+ // mln_precondition(is_valid());
+ return site_;
}
template <typename S, typename E>
@@ -270,7 +310,7 @@ namespace mln
inline
graph_psite_base<S,E>::operator const typename S::graph_element&() const
{
- mln_precondition(is_valid());
+ //mln_precondition(is_valid());
return elt_;
}
@@ -279,20 +319,23 @@ namespace mln
const typename S::graph_element&
graph_psite_base<S,E>::element() const
{
- mln_precondition(is_valid());
+ /*FIXME: we may like to enable the following precondition, however, we
+ ** can't do that since neighb_*_niters update the psite target after having
+ ** taken the adress of the subject.
+ */
+ // mln_precondition(is_valid());
return elt_;
}
template <typename S, typename E>
inline
const typename S::graph_element&
- graph_psite_base<S,E>::hook_elt_() const
+ graph_psite_base<S,E>::p_hook_() const
{
return elt_;
}
-
- /*--------------.
+ /*--------------.
| Comparisons. |
`--------------*/
@@ -320,6 +363,105 @@ namespace mln
return lhs.id() < rhs.id();
}
+
+ template <typename S, typename P, typename E>
+ inline
+ const E&
+ subject_impl< const graph_psite_base<S,P>&, E >::exact_() const
+ {
+ return internal::force_exact<const E>(*this);
+ }
+
+ template <typename S, typename P, typename E>
+ inline
+ const S*
+ subject_impl< const graph_psite_base<S,P>&, E >::target_() const
+ {
+ return exact_().get_subject().target();
+ }
+
+ template <typename S, typename P, typename E>
+ inline
+ const S&
+ subject_impl< const graph_psite_base<S,P>&, E >::site_set() const
+ {
+ return exact_().get_subject().site_set();
+ }
+
+
+ template <typename S, typename P, typename E>
+ inline
+ const typename S::graph_t&
+ subject_impl< const graph_psite_base<S,P>&, E >::graph() const
+ {
+ return exact_().get_subject().graph();
+ }
+
+ template <typename S, typename P, typename E>
+ inline
+ unsigned
+ subject_impl< const graph_psite_base<S,P>&, E >::id() const
+ {
+ return exact_().get_subject().id();
+ };
+
+ template <typename S, typename P, typename E>
+ inline
+ bool
+ subject_impl< const graph_psite_base<S,P>&, E >::is_valid() const
+ {
+ return exact_().get_subject().is_valid();
+ }
+
+ template <typename S, typename P, typename E>
+ inline
+ const typename S::graph_element&
+ subject_impl< const graph_psite_base<S,P>&, E >::element() const
+ {
+ return exact_().get_subject().element();
+ }
+
+ template <typename S, typename P, typename E>
+ inline
+ const typename S::graph_element&
+ subject_impl< const graph_psite_base<S,P>&, E >::p_hook_() const
+ {
+ return exact_().get_subject().p_hook_();
+ }
+
+
+ template <typename S, typename P, typename E>
+ inline
+ E&
+ subject_impl< graph_psite_base<S,P>&, E >::exact_()
+ {
+ return internal::force_exact<E>(*this);
+ }
+
+ template <typename S, typename P, typename E>
+ inline
+ void
+ subject_impl< graph_psite_base<S,P>&, E >::change_target(const S& new_target)
+ {
+ exact_().get_subject().change_target(new_target);
+ }
+
+ template <typename S, typename P, typename E>
+ inline
+ void
+ subject_impl< graph_psite_base<S,P>&, E >::update_id(unsigned id)
+ {
+ exact_().get_subject().update_id(id);
+ };
+
+ template <typename S, typename P, typename E>
+ inline
+ void
+ subject_impl< graph_psite_base<S,P>&, E >::invalidate()
+ {
+ exact_().get_subject().invalidate();
+ }
+
# endif // ! MLN_INCLUDE_ONLY
} // end of namespace internal
diff --git a/milena/mln/core/routine/duplicate.hh b/milena/mln/core/routine/duplicate.hh
index cd1982f..579cf1e 100644
--- a/milena/mln/core/routine/duplicate.hh
+++ b/milena/mln/core/routine/duplicate.hh
@@ -1,4 +1,5 @@
-// Copyright (C) 2007 EPITA Research and Development Laboratory
+// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory
+// (LRDE)
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -25,13 +26,12 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef MLN_CORE_ROUTINE_CLONE_HH
-# define MLN_CORE_ROUTINE_CLONE_HH
+#ifndef MLN_CORE_ROUTINE_DUPLICATE_HH
+# define MLN_CORE_ROUTINE_DUPLICATE_HH
-/*! \file mln/core/routine/duplicate.hh
- *
- * \brief Clone an image, that is, get an effective copy.
- */
+/// \file mln/core/routine/duplicate.hh
+///
+/// Clone an image, that is, get an effective copy.
# include <mln/core/concept/image.hh>
# include <mln/core/routine/init.hh>
@@ -41,14 +41,13 @@
namespace mln
{
- /*! \brief Clone the image \p model with the values of the image \p
- * data.
- *
- * \param[in] model The image to be duplicateed.
- * \result The duplicate.
- *
- * \pre model.has_data
- */
+ /// Duplicate the image \p model with the values of the image \p
+ /// data.
+ ///
+ /// \param[in] model The image to be duplicated.
+ /// \result The duplicate.
+ ///
+ /// \pre model.has_data
template <typename I>
mln_concrete(I) duplicate(const Image<I>& model);
@@ -75,4 +74,4 @@ namespace mln
} // end of namespace mln
-#endif // ! MLN_CORE_ROUTINE_CLONE_HH
+#endif // ! MLN_CORE_ROUTINE_DUPLICATE_HH
diff --git a/milena/mln/core/site_set/p_vaccess.hh b/milena/mln/core/site_set/p_vaccess.hh
index 44e1f38..25b8e5c 100644
--- a/milena/mln/core/site_set/p_vaccess.hh
+++ b/milena/mln/core/site_set/p_vaccess.hh
@@ -34,6 +34,7 @@
/// \todo Fix the FIXMEs.
# include <utility>
+# include <mln/core/concept/site_set.hh>
# include <mln/core/site_set/p_double.hh>
# include <mln/core/internal/site_set_base.hh>
# include <mln/core/internal/pseudo_site_base.hh>
@@ -41,7 +42,6 @@
# include <mln/value/set.hh>
-
namespace mln
{
@@ -66,8 +66,7 @@ namespace mln
- /*! \brief FIXME
- */
+ /// FIXME
template <typename V, typename S>
class p_vaccess : public internal::site_set_base_< mln_site(S),
p_vaccess<V,S> >,
@@ -111,14 +110,14 @@ namespace mln
/// site set.
bool has(const V& v, const mln_psite(S)& p) const;
- /// Test if this site set is valid.
+ /// Test if this site set is valid.
bool is_valid() const;
/// Element associated type.
typedef mln_element(S) element;
- /// Insertion element associated type.
+ /// Insertion element associated type.
typedef std::pair<V, element> i_element;
/// Insert a pair \p v_e (value v, element e).
@@ -145,7 +144,7 @@ namespace mln
// Required by p_double-related classes.
const mln::value::set<V>& set_1_() const;
const S& set_2_(const V& v) const;
-
+
protected:
mln::value::set<V> vs_;
diff --git a/milena/mln/fun/i2v/array.hh b/milena/mln/fun/i2v/array.hh
index f9ce0d1..6b6754a 100644
--- a/milena/mln/fun/i2v/array.hh
+++ b/milena/mln/fun/i2v/array.hh
@@ -37,6 +37,7 @@
# include <vector>
# include <algorithm>
+# include <mln/core/concept/function.hh>
# include <mln/fun/internal/array_base.hh>
# include <mln/util/array.hh>
@@ -88,12 +89,16 @@ namespace mln
{
template <typename T>
- class array : public internal::array_base< T, array<T> >
+ class array : public Function_i2v< array<T> >,
+ public internal::array_base<T>
{
- typedef internal::array_base< T, array<T> > super_base_;
+ typedef internal::array_base<T> super_base_;
public:
+ /// Mutable result type. The function results can be modified.
+ typedef typename super_base_::mutable_result mutable_result;
+
/// Constructors
/// \{
diff --git a/milena/mln/fun/internal/array_base.hh b/milena/mln/fun/internal/array_base.hh
index 3782ca4..e26ab91 100644
--- a/milena/mln/fun/internal/array_base.hh
+++ b/milena/mln/fun/internal/array_base.hh
@@ -34,7 +34,6 @@
# include <vector>
# include <algorithm>
-# include <mln/core/concept/function.hh>
# include <mln/util/array.hh>
# include <mln/tag/init.hh>
@@ -48,8 +47,8 @@ namespace mln
namespace internal
{
- template <typename T, typename E>
- class array_base : public Function_i2v< E >
+ template <typename T>
+ class array_base
{
public:
@@ -114,88 +113,88 @@ namespace mln
namespace internal
{
- template <typename T, typename E>
+ template <typename T>
inline
- array_base<T,E>::array_base()
+ array_base<T>::array_base()
{
}
- template <typename T, typename E>
+ template <typename T>
inline
- array_base<T,E>::array_base(unsigned n)
+ array_base<T>::array_base(unsigned n)
: v_(n)
{
}
- template <typename T, typename E>
+ template <typename T>
inline
- array_base<T,E>::array_base(unsigned n, const T& val)
+ array_base<T>::array_base(unsigned n, const T& val)
: v_(n, val)
{
}
- template <typename T, typename E>
+ template <typename T>
inline
- array_base<T,E>::array_base(const util::array<T>& from)
+ array_base<T>::array_base(const util::array<T>& from)
: v_(from.std_vector())
{
}
- template <typename T, typename E>
+ template <typename T>
inline
- array_base<T,E>::array_base(const std::vector<T>& from)
+ array_base<T>::array_base(const std::vector<T>& from)
: v_(from)
{
}
- template <typename T, typename E>
+ template <typename T>
inline
void
- array_base<T,E>::resize(unsigned n)
+ array_base<T>::resize(unsigned n)
{
v_.resize(n);
}
- template <typename T, typename E>
+ template <typename T>
inline
void
- array_base<T,E>::resize(unsigned n, const T& val)
+ array_base<T>::resize(unsigned n, const T& val)
{
v_.resize(n, val);
}
- template <typename T, typename E>
+ template <typename T>
inline
unsigned
- array_base<T,E>::size() const
+ array_base<T>::size() const
{
return v_.size();
}
- template <typename T, typename E>
+ template <typename T>
inline
- typename array_base<T,E>::result
- array_base<T,E>::operator()(unsigned i) const
+ typename array_base<T>::result
+ array_base<T>::operator()(unsigned i) const
{
mln_precondition(i < v_.size());
return v_[i];
}
- template <typename T, typename E>
+ template <typename T>
inline
- typename array_base<T,E>::mutable_result
- array_base<T,E>::operator()(unsigned i)
+ typename array_base<T>::mutable_result
+ array_base<T>::operator()(unsigned i)
{
mln_precondition(i < v_.size());
return v_[i];
}
- template <typename T, typename E>
+ template <typename T>
inline
void
- array_base<T,E>::init_(unsigned n)
+ array_base<T>::init_(unsigned n)
{
v_.resize(n);
}
diff --git a/milena/mln/fun/l2l/relabel.hh b/milena/mln/fun/l2l/relabel.hh
index 0950e01..16da5b4 100644
--- a/milena/mln/fun/l2l/relabel.hh
+++ b/milena/mln/fun/l2l/relabel.hh
@@ -35,6 +35,7 @@
# include <vector>
# include <algorithm>
+# include <mln/core/concept/function.hh>
# include <mln/fun/internal/array_base.hh>
# include <mln/util/array.hh>
# include <mln/metal/converts_to.hh>
@@ -89,12 +90,16 @@ namespace mln
{
template <typename L>
- class relabel : public internal::array_base< L, relabel<L> >
+ class relabel : public Function_l2l< relabel<L> >,
+ public internal::array_base<L>
{
- typedef internal::array_base< L, relabel<L> > super_base_;
+ typedef internal::array_base<L> super_base_;
public:
+ /// Mutable result type. The function results can be modified.
+ typedef typename super_base_::mutable_result mutable_result;
+
/// Constructors
/// \{
diff --git a/milena/mln/fun/p2b/chess.hh b/milena/mln/fun/p2b/chess.hh
index 2f73cf9..a4c18a4 100644
--- a/milena/mln/fun/p2b/chess.hh
+++ b/milena/mln/fun/p2b/chess.hh
@@ -1,4 +1,5 @@
-// Copyright (C) 2007 EPITA Research and Development Laboratory
+// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory
+// (LRDE)
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -28,10 +29,9 @@
#ifndef MLN_FUN_P2B_CHESS_HH
# define MLN_FUN_P2B_CHESS_HH
-/*! \file mln/fun/p2b/chess.hh
- *
- * \brief FIXME.
- */
+/// \file mln/fun/p2b/chess.hh
+///
+/// FIXME.
# include <mln/core/concept/function.hh>
# include <mln/core/alias/point2d.hh>
diff --git a/milena/mln/geom/ninds.hh b/milena/mln/geom/ninds.hh
index 9ab0d1a..12fd520 100644
--- a/milena/mln/geom/ninds.hh
+++ b/milena/mln/geom/ninds.hh
@@ -1,4 +1,5 @@
-// Copyright (C) 2007 EPITA Research and Development Laboratory
+// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory
+// (LRDE)
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -28,10 +29,9 @@
#ifndef MLN_GEOM_NINDS_HH
# define MLN_GEOM_NINDS_HH
-/*! \file mln/geom/ninds.hh
- *
- * \brief Give the number of inds of an image.
- */
+/// \file mln/geom/ninds.hh
+///
+/// Give the number of inds of an image.
# include <mln/geom/min_ind.hh>
# include <mln/geom/max_ind.hh>
diff --git a/milena/mln/labeling/relabel.hh b/milena/mln/labeling/relabel.hh
index 551da6d..660e25b 100644
--- a/milena/mln/labeling/relabel.hh
+++ b/milena/mln/labeling/relabel.hh
@@ -148,15 +148,13 @@ namespace mln
relabel(const Image<I>& label,
const mln_value(I)& nlabels,
mln_value(I)& new_nlabels,
- const Function_l2b<F>& fl2b)
+ const Function_l2l<F>& fl2l)
{
trace::entering("labeling::relabel");
- internal::relabel_tests(label, nlabels, new_nlabels, fl2b);
+ internal::relabel_tests(label, nlabels, new_nlabels, fl2l);
- typedef fun::l2l::relabel<mln_value(I)> fl2l_t;
- fl2l_t fl2l = make::relabelfun(fl2b, nlabels, new_nlabels);
- mln_concrete(I) output = labeling::relabel(label, nlabels, new_nlabels, fl2l);
+ mln_concrete(I) output = level::transform(label, fl2l);
trace::exiting("labeling::relabel");
return output;
@@ -170,13 +168,15 @@ namespace mln
relabel(const Image<I>& label,
const mln_value(I)& nlabels,
mln_value(I)& new_nlabels,
- const Function_l2l<F>& fl2l)
+ const Function_l2b<F>& fl2b)
{
trace::entering("labeling::relabel");
- internal::relabel_tests(label, nlabels, new_nlabels, fl2l);
+ internal::relabel_tests(label, nlabels, new_nlabels, fl2b);
- mln_concrete(I) output = level::transform(label, fl2l);
+ typedef fun::l2l::relabel<mln_value(I)> fl2l_t;
+ fl2l_t fl2l = make::relabelfun(fl2b, nlabels, new_nlabels);
+ mln_concrete(I) output = labeling::relabel(label, nlabels, new_nlabels, fl2l);
trace::exiting("labeling::relabel");
return output;
@@ -189,15 +189,13 @@ namespace mln
void
relabel_inplace(Image<I>& label,
mln_value(I)& nlabels,
- const Function_l2b<F>& fl2b)
+ const Function_l2l<F>& fl2l)
{
trace::entering("labeling::relabel_inplace");
- internal::relabel_inplace_tests(label, nlabels, fl2b);
+ internal::relabel_inplace_tests(label, nlabels, fl2l);
- typedef fun::l2l::relabel<mln_value(I)> fl2l_t;
- fl2l_t fl2l = make::relabelfun(fl2b, nlabels, nlabels);
- relabel_inplace(label, nlabels, fl2l);
+ level::transform_inplace(label, fl2l);
trace::exiting("labeling::relabel_inplace");
}
@@ -209,18 +207,19 @@ namespace mln
void
relabel_inplace(Image<I>& label,
mln_value(I)& nlabels,
- const Function_l2l<F>& fl2l)
+ const Function_l2b<F>& fl2b)
{
trace::entering("labeling::relabel_inplace");
- internal::relabel_inplace_tests(label, nlabels, fl2l);
+ internal::relabel_inplace_tests(label, nlabels, fl2b);
- level::transform_inplace(label, fl2l);
+ typedef fun::l2l::relabel<mln_value(I)> fl2l_t;
+ fl2l_t fl2l = make::relabelfun(fl2b, nlabels, nlabels);
+ labeling::relabel_inplace(label, nlabels, fl2l);
trace::exiting("labeling::relabel_inplace");
}
-
# endif // ! MLN_INCLUDE_ONLY
} // end of namespace mln::labeling
diff --git a/milena/mln/linear/gaussian.hh b/milena/mln/linear/gaussian.hh
index d550123..4b5be0c 100644
--- a/milena/mln/linear/gaussian.hh
+++ b/milena/mln/linear/gaussian.hh
@@ -41,9 +41,13 @@
# include <mln/core/concept/image.hh>
# include <mln/core/alias/point2d.hh>
+# include <mln/core/alias/dpoint1d.hh>
+# include <mln/core/alias/dpoint3d.hh>
# include <mln/extension/adjust_fill.hh>
# include <mln/geom/ncols.hh>
# include <mln/geom/nrows.hh>
+# include <mln/geom/ninds.hh>
+# include <mln/geom/nslis.hh>
# include <mln/data/paste.hh>
# include <mln/level/stretch.hh>
# include <mln/algebra/vec.hh>
@@ -449,7 +453,7 @@ namespace mln
static_cast<def::coord>(k)),
point3d(static_cast<def::coord>(i),
static_cast<def::coord>(geom::nrows(img) - 1 +
- img.border()),
+ img.border()),
static_cast<def::coord>(k)),
geom::nrows(img) + 2 *
img.border(),
diff --git a/milena/mln/morpho/opening_area_on_vertices.hh b/milena/mln/morpho/opening_area_on_vertices.hh
index 80c6053..a1d3b72 100644
--- a/milena/mln/morpho/opening_area_on_vertices.hh
+++ b/milena/mln/morpho/opening_area_on_vertices.hh
@@ -52,7 +52,7 @@ namespace mln
template <typename P2V, typename G, typename V2P, typename N>
pw::image<P2V, p_edges<G, V2P> >
opening_area_on_vertices(const pw::image<P2V, p_edges<G, V2P> >& input,
- const Neighborhood<N>& nbh);
+ const Neighborhood<N>& nbh, unsigned lambda);
# ifndef MLN_INCLUDE_ONLY
diff --git a/milena/mln/pw/cst.hh b/milena/mln/pw/cst.hh
index e9e01f9..bc344ad 100644
--- a/milena/mln/pw/cst.hh
+++ b/milena/mln/pw/cst.hh
@@ -1,4 +1,5 @@
// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory
+// (LRDE)
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -28,10 +29,9 @@
#ifndef MLN_PW_CST_HH
# define MLN_PW_CST_HH
-/*! \file mln/pw/cst.hh
- *
- * \brief FIXME.
- */
+/// \file mln/pw/cst.hh
+///
+/// FIXME.
# include <mln/fun/internal/selector.hh>
diff --git a/milena/mln/pw/value.hh b/milena/mln/pw/value.hh
index 5dacaad..c237653 100644
--- a/milena/mln/pw/value.hh
+++ b/milena/mln/pw/value.hh
@@ -1,4 +1,5 @@
-// Copyright (C) 2007 EPITA Research and Development Laboratory
+// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory
+// (LRDE)
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -28,10 +29,9 @@
#ifndef MLN_PW_VALUE_HH
# define MLN_PW_VALUE_HH
-/*! \file mln/pw/value.hh
- *
- * \brief FIXME.
- */
+/// \file mln/pw/value.hh
+///
+/// FIXME.
# include <mln/fun/internal/selector.hh>
# include <mln/core/concept/image.hh>
@@ -52,10 +52,12 @@ namespace mln
: fun::internal::selector_p2_< mln_value(I), value_<I> >::ret
{
typedef mln_value(I) result;
+
+ value_();
value_(const I& ima);
+
mln_rvalue(I) operator()(const mln_psite(I)& p) const;
- value_(); // A function should have a ctor without arg so that "initialize" can work.
protected:
const I* ima_;
};
@@ -63,7 +65,7 @@ namespace mln
// FIXME: Doc!
-
+
template <typename I>
value_<I> value(const Image<I>& ima);
@@ -75,15 +77,15 @@ namespace mln
template <typename I>
inline
- value_<I>::value_(const I& ima)
- : ima_(&ima)
+ value_<I>::value_()
+ : ima_(0)
{
}
template <typename I>
inline
- value_<I>::value_()
- : ima_(0)
+ value_<I>::value_(const I& ima)
+ : ima_(&ima)
{
}
@@ -97,8 +99,9 @@ namespace mln
return (*ima_)(p);
}
+
// pw::value(ima)
-
+
template <typename I>
inline
value_<I>
diff --git a/milena/mln/registration/get_rot.hh b/milena/mln/registration/get_rot.hh
index 6742abc..b258937 100644
--- a/milena/mln/registration/get_rot.hh
+++ b/milena/mln/registration/get_rot.hh
@@ -61,6 +61,11 @@ namespace mln
const M& map,
const algebra::vec<2u,float>& mu_xk)
{
+ (void) c;
+ (void) mu_c;
+ (void) ck;
+ (void) map;
+ (void) mu_xk;
//FIXME: Write 2d version of rotation computation betwenn two p_array
return fun::x2x::rotation<2u, float>();
}
diff --git a/milena/mln/registration/registration.hh b/milena/mln/registration/registration.hh
index 41a531d..81925ed 100644
--- a/milena/mln/registration/registration.hh
+++ b/milena/mln/registration/registration.hh
@@ -28,10 +28,9 @@
#ifndef MLN_REGISTRATION_REGISTRATION_HH
# define MLN_REGISTRATION_REGISTRATION_HH
-/*! \file mln/registration/registration.hh
- *
- * \brief image registration
- */
+/// \file mln/registration/registration.hh
+///
+/// image registration
# include <mln/registration/icp.hh>
# include <mln/fun/x2x/all.hh>
@@ -47,8 +46,7 @@ namespace mln
using namespace mln::fun::x2x;
- /*! Register an image \p cloud over the image \p surface.
- */
+ /// Register an image \p cloud over the image \p surface.
template <typename I, typename J>
inline
composed< rotation<I::psite::dim, float>, translation<I::psite::dim, float> >
diff --git a/milena/mln/util/ord_pair.hh b/milena/mln/util/ord_pair.hh
index 79fef46..9802fab 100644
--- a/milena/mln/util/ord_pair.hh
+++ b/milena/mln/util/ord_pair.hh
@@ -30,7 +30,8 @@
# define MLN_UTIL_ORD_PAIR_HH
/// \file mln/util/ord_pair.hh
-/// \brief Definition of an ordered pair.
+///
+/// Definition of an ordered pair.
# include <mln/core/concept/object.hh>
# include <mln/util/ord.hh>
@@ -44,13 +45,14 @@ namespace mln
// FIXME: Rename as ord_pair.
- /// \brief Ordered pair structure s.a. this->first <= this->second;
+ /// Ordered pair structure s.a. this->first <= this->second;
/// ordered pairs are partially ordered using lexicographical
/// ordering.
template <typename T>
struct ord_pair : public mln::Object< ord_pair<T> >
{
public:
+ ord_pair();
ord_pair(const T& val1, const T& val2);
public:
@@ -66,21 +68,21 @@ namespace mln
T& second();
/// \}
- /// \brief Replace the first member of the pair by \a val, while
+ /// Replace the first member of the pair by \a val, while
/// keeping the relative order.
///
/// \post \a first_ <= \a second_ (with <= being the
/// mln::util::ord_weak relationship).
void change_first(const T& val);
- /// \brief Replace the second member of the pair by \a val,
+ /// Replace the second member of the pair by \a val,
/// while keeping the relative order.
///
/// \post \a first_ <= \a second_ (with <= being the
/// mln::util::ord_weak relationship).
void change_second(const T& val);
- /// \brief Replace both members of the pair by \a val, while
+ /// Replace both members of the pair by \a val, while
/// keeping the relative order.
///
/// \post \a first_ <= \a second_ (with <= being the
@@ -128,6 +130,12 @@ namespace mln
template <typename T>
inline
+ ord_pair<T>::ord_pair()
+ {
+ }
+
+ template <typename T>
+ inline
ord_pair<T>::ord_pair(const T& val1, const T& val2)
{
change_both(val1, val2);
diff --git a/milena/mln/util/site_pair.hh b/milena/mln/util/site_pair.hh
index b9a5611..9bb3162 100644
--- a/milena/mln/util/site_pair.hh
+++ b/milena/mln/util/site_pair.hh
@@ -28,10 +28,12 @@
#ifndef MLN_UTIL_SITE_PAIR_HH
# define MLN_UTIL_SITE_PAIR_HH
+# include <mln/core/concept/proxy.hh>
# include <mln/util/ord_pair.hh>
/// \file mln/util/site_pair.hh
-/// \brief Definition of a site pair type.
+///
+/// Definition of a site pair type.
namespace mln
{
@@ -44,8 +46,9 @@ namespace mln
Hence this small workaround. Use ord_pair directly as soon as
image_base is refurbished. */
template <typename P>
- struct site_pair : public mln::Object< site_pair<P> >
+ class site_pair : public mln::Object< site_pair<P> >
{
+ public:
/* FIXME: We should not need to define this typedef
(see. mln::internal::image_base's site `coord' typedef). */
typedef mln_coord(P) coord;
@@ -53,6 +56,15 @@ namespace mln
site_pair();
site_pair(const P& first, const P& second);
+ /// Return the first site.
+ const P& first() const;
+ /// Return the second site.
+ const P& second() const;
+
+ /// Return the underlying pair.
+ const util::ord_pair<P>& pair() const;
+
+ private:
util::ord_pair<P> pair_;
};
@@ -71,17 +83,43 @@ namespace mln
template <typename P>
bool operator< (const site_pair<P>& lhs, const site_pair<P>& rhs);
+ } // end of namespace mln::util
+
+
+ namespace internal
+ {
+
+ /// \{
+ /// subject_impl specialization (Proxy)
+
+ template <typename P, typename E>
+ struct subject_impl< const util::site_pair<P>, E >
+ {
+ const P& first() const;
+ const P& second() const;
+ const util::ord_pair<P>& pair() const;
+
+ private:
+ const E& exact_() const;
+ };
+
+ /// \}
+
+ } // end of namespace mln::internal
+
# ifndef MLN_INCLUDE_ONLY
+ namespace util
+ {
+
/*---------------.
| Construction. |
`---------------*/
template <typename P>
site_pair<P>::site_pair()
- : pair_(P(), P())
{
}
@@ -91,6 +129,30 @@ namespace mln
{
}
+ template <typename P>
+ inline
+ const P&
+ site_pair<P>::first() const
+ {
+ return pair_.first();
+ }
+
+ template <typename P>
+ inline
+ const P&
+ site_pair<P>::second() const
+ {
+ return pair_.second();
+ }
+
+ template <typename P>
+ inline
+ const util::ord_pair<P>&
+ site_pair<P>::pair() const
+ {
+ return pair_;
+ }
+
/*-------------.
| Comparison. |
`-------------*/
@@ -100,7 +162,7 @@ namespace mln
bool
operator==(const site_pair<P>& lhs, const site_pair<P>& rhs)
{
- return lhs.pair_ == rhs.pair_;
+ return lhs.pair() == rhs.pair();
}
template <typename P>
@@ -108,7 +170,7 @@ namespace mln
bool
operator< (const site_pair<P>& lhs, const site_pair<P>& rhs)
{
- return lhs.pair_ < rhs.pair_;
+ return lhs.pair() < rhs.pair();
}
template <typename P>
@@ -116,13 +178,42 @@ namespace mln
bool
operator<=(const site_pair<P>& lhs, const site_pair<P>& rhs)
{
- return lhs.pair_ <= rhs.pair_;
+ return lhs.pair() <= rhs.pair();
}
-# endif // ! MLN_INCLUDE_ONLY
-
} // end of mln::util
+ namespace internal
+ {
+
+ template <typename P, typename E>
+ inline
+ const E&
+ subject_impl< const util::site_pair<P>, E >::exact_() const
+ {
+ return internal::force_exact<const E>(*this);
+ }
+
+ template <typename P, typename E>
+ inline
+ const P&
+ subject_impl< const util::site_pair<P>, E >::first() const
+ {
+ return exact_().get_subject().first();
+ }
+
+ template <typename P, typename E>
+ inline
+ const P&
+ subject_impl< const util::site_pair<P>, E >::second() const
+ {
+ return exact_().get_subject().second();
+ }
+
+ } // end of namespace mln::internal
+
+# endif // ! MLN_INCLUDE_ONLY
+
} // end of mln
diff --git a/milena/mln/win/multiple_size.hh b/milena/mln/win/multiple_size.hh
index beede96..86ccaed 100644
--- a/milena/mln/win/multiple_size.hh
+++ b/milena/mln/win/multiple_size.hh
@@ -130,7 +130,7 @@ namespace mln
template <unsigned n, typename W, typename F>
- class multiple_size_qiter
+ class multiple_size_qiter
: public internal::site_relative_iterator_base< multiple_size<n,W,F>,
multiple_size_qiter<n,W,F> >
{
@@ -155,6 +155,10 @@ namespace mln
/// Go to the next point.
void do_next_();
+ /// Do some work while setting the reference site.
+ template <typename Pref>
+ void center_at_(const Pref&);
+
/// Compute the current psite.
mln_psite(W) compute_p_() const;
@@ -349,6 +353,14 @@ namespace mln
}
template <unsigned n, typename W, typename F>
+ template <typename Pref>
+ inline
+ void
+ multiple_size_qiter<n,W,F>::center_at_(const Pref&)
+ {
+ }
+
+ template <unsigned n, typename W, typename F>
inline
mln_psite(W)
multiple_size_qiter<n,W,F>::compute_p_() const
diff --git a/milena/tests/unit_test/Makefile.am b/milena/tests/unit_test/Makefile.am
index 2f3426e..91e56f5 100644
--- a/milena/tests/unit_test/Makefile.am
+++ b/milena/tests/unit_test/Makefile.am
@@ -21,7 +21,6 @@ mln_geom_size3d \
mln_geom_ninds \
mln_geom_nslis \
mln_geom_delta \
-mln_geom_resize \
mln_geom_nsites \
mln_geom_min_col \
mln_geom_complex_geometry \
@@ -1028,7 +1027,6 @@ mln_geom_size3d_SOURCES = mln_geom_size3d.cc
mln_geom_ninds_SOURCES = mln_geom_ninds.cc
mln_geom_nslis_SOURCES = mln_geom_nslis.cc
mln_geom_delta_SOURCES = mln_geom_delta.cc
-mln_geom_resize_SOURCES = mln_geom_resize.cc
mln_geom_nsites_SOURCES = mln_geom_nsites.cc
mln_geom_min_col_SOURCES = mln_geom_min_col.cc
mln_geom_complex_geometry_SOURCES = mln_geom_complex_geometry.cc
diff --git a/milena/tests/unit_test/mln_geom_resize.cc b/milena/tests/unit_test/mln_geom_resize.cc
deleted file mode 100644
index c1bac73..0000000
--- a/milena/tests/unit_test/mln_geom_resize.cc
+++ /dev/null
@@ -1,11 +0,0 @@
-// Unit test for mln/geom/resize.hh.
-// Generated by ./build_unit_test.sh, do not modify.
-
-// Include the file twice, so we detect missing inclusion guards.
-#include <mln/geom/resize.hh>
-#include <mln/geom/resize.hh>
-
-int main()
-{
- // Nothing.
-}
--
1.5.6.5
1
0
* mln/accu/convolve.hh,
* mln/algebra/mat.hh,
* mln/algebra/vec.hh,
* mln/fun/v2v/norm.hh,
* mln/linear/ch_convolve.hh,
* mln/metal/array1d.hh,
* mln/metal/array2d.hh,
* mln/metal/array3d.hh,
* mln/metal/mat.hh,
* mln/metal/vec.hh,
* mln/value/ops.hh: rename mln_sum_x to mln_sum_product.
* mln/norm/l1.hh,
* mln/norm/l2.hh: use mln_sum_product instead of mln_sum according to
the fixme.
---
milena/ChangeLog | 20 +++++++++++++++
milena/mln/accu/convolve.hh | 7 +++--
milena/mln/algebra/mat.hh | 20 ++++++++--------
milena/mln/algebra/vec.hh | 15 ++++++-----
milena/mln/fun/v2v/norm.hh | 48 +++++++++++++++++--------------------
milena/mln/linear/ch_convolve.hh | 4 +-
milena/mln/metal/array1d.hh | 2 +-
milena/mln/metal/array2d.hh | 2 +-
milena/mln/metal/array3d.hh | 2 +-
milena/mln/metal/mat.hh | 20 ++++++++--------
milena/mln/metal/vec.hh | 8 +++---
milena/mln/norm/l1.hh | 31 +++++++++++-------------
milena/mln/norm/l2.hh | 42 +++++++++++++++-----------------
milena/mln/value/ops.hh | 4 +-
14 files changed, 119 insertions(+), 106 deletions(-)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index 681224f..f5bebd3 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,3 +1,23 @@
+2008-12-30 Guillaume Lazzara <z(a)lrde.epita.fr>
+
+ Rename mln_sum_x to mln_sum_product.
+
+ * mln/accu/convolve.hh,
+ * mln/algebra/mat.hh,
+ * mln/algebra/vec.hh,
+ * mln/fun/v2v/norm.hh,
+ * mln/linear/ch_convolve.hh,
+ * mln/metal/array1d.hh,
+ * mln/metal/array2d.hh,
+ * mln/metal/array3d.hh,
+ * mln/metal/mat.hh,
+ * mln/metal/vec.hh,
+ * mln/value/ops.hh: rename mln_sum_x to mln_sum_product.
+
+ * mln/norm/l1.hh,
+ * mln/norm/l2.hh: use mln_sum_product instead of mln_sum according to
+ the fixme.
+
2008-12-30 Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
Fix warnings due to g++ -Wconversion option.
diff --git a/milena/mln/accu/convolve.hh b/milena/mln/accu/convolve.hh
index de20998..0769f1a 100644
--- a/milena/mln/accu/convolve.hh
+++ b/milena/mln/accu/convolve.hh
@@ -50,9 +50,10 @@ namespace mln
/// convolved. Parameter \c R is the result type.
///
template <typename T1, typename T2,
- typename R = mln_sum_x(T1, T2)>
+ typename R = mln_sum_product(T1, T2)>
struct convolve : public mln::accu::internal::base< R, convolve<T1,T2,R> >,
- private metal::converts_to< mln_sum_x(T1, T2), R >::check_t
+ private metal::converts_to< mln_sum_product(T1, T2),
+ R >::check_t
{
typedef std::pair<T1,T2> argument;
@@ -75,7 +76,7 @@ namespace mln
protected:
- typedef mln_sum_x(T1, T2) S;
+ typedef mln_sum_product(T1, T2) S;
S s_;
};
diff --git a/milena/mln/algebra/mat.hh b/milena/mln/algebra/mat.hh
index 9fd5931..08b8ee2 100644
--- a/milena/mln/algebra/mat.hh
+++ b/milena/mln/algebra/mat.hh
@@ -152,13 +152,13 @@ namespace mln
unsigned m, typename U >
struct set_precise_binary_< op::times, algebra::mat<n,o,T>, algebra::mat<o,m,U> >
{
- typedef algebra::mat<n, m, mln_sum_x(T, U)> ret;
+ typedef algebra::mat<n, m, mln_sum_product(T, U)> ret;
};
template < unsigned n, typename T, typename U >
struct set_precise_binary_< op::times, algebra::mat<n,n,T>, algebra::mat<n,n,U> >
{ // Disambiguate between both previous defs.
- typedef algebra::mat<n, n, mln_sum_x(T, U)> ret;
+ typedef algebra::mat<n, n, mln_sum_product(T, U)> ret;
};
// mat * vec
@@ -167,7 +167,7 @@ namespace mln
typename U >
struct set_precise_binary_< op::times, algebra::mat<n,m,T>, algebra::vec<m,U> >
{
- typedef algebra::vec<n, mln_sum_x(T, U)> ret;
+ typedef algebra::vec<n, mln_sum_product(T, U)> ret;
};
// mat * s
@@ -226,14 +226,14 @@ namespace mln
template <unsigned n, unsigned o, typename T,
unsigned m, typename U>
- mat<n, m, mln_sum_x(T,U)>
+ mat<n, m, mln_sum_product(T,U)>
operator*(const mat<n,o,T>& lhs, const mat<o,m,U>& rhs);
// mat * vec
template <unsigned n, unsigned m, typename T,
typename U>
- vec<n, mln_sum_x(T,U)>
+ vec<n, mln_sum_product(T,U)>
operator*(const mat<n,m,T>& lhs, const vec<m,U>& rhs);
// mat * s
@@ -424,10 +424,10 @@ namespace mln
template <unsigned n, unsigned o, typename T,
unsigned m, typename U>
inline
- mat<n, m, mln_sum_x(T,U)>
+ mat<n, m, mln_sum_product(T,U)>
operator*(const mat<n,o,T>& lhs, const mat<o,m,U>& rhs)
{
- mat<n,m, mln_sum_x(T,U)> tmp;
+ mat<n,m, mln_sum_product(T,U)> tmp;
for (unsigned i = 0; i < n; ++i)
for (unsigned j = 0; j < m; ++j)
{
@@ -441,13 +441,13 @@ namespace mln
template <unsigned n, unsigned m, typename T,
typename U>
inline
- vec<n, mln_sum_x(T,U)>
+ vec<n, mln_sum_product(T,U)>
operator*(const mat<n,m,T>& lhs, const vec<m,U>& rhs)
{
- vec<n, mln_sum_x(T,U)> tmp;
+ vec<n, mln_sum_product(T,U)> tmp;
for (unsigned i = 0; i < n; ++i)
{
- mln_sum_x(T,U) sum(literal::zero);
+ mln_sum_product(T,U) sum(literal::zero);
for (unsigned j = 0; j < m; ++j)
sum += lhs(i, j) * rhs[j];
tmp[i] = sum;
diff --git a/milena/mln/algebra/vec.hh b/milena/mln/algebra/vec.hh
index 1434930..da2541c 100644
--- a/milena/mln/algebra/vec.hh
+++ b/milena/mln/algebra/vec.hh
@@ -48,7 +48,6 @@
# include <mln/value/ops.hh>
-
// FIXME: Document.
@@ -67,7 +66,7 @@ namespace mln
namespace norm {
template <unsigned n, typename C>
- mln_sum(C) l2(const algebra::vec<n,C>& vec);
+ mln_sum_product(C,C) l2(const algebra::vec<n,C>& vec);
}
@@ -273,7 +272,7 @@ namespace mln
struct set_precise_binary_< op::times,
algebra::vec<n, T>, algebra::vec<n, U> >
{
- typedef mln_sum_x(T,U) ret;
+ typedef mln_sum_product(T,U) ret;
};
template < template <class, class> class Name,
@@ -325,7 +324,7 @@ namespace mln
/// Scalar product (dot product).
template <unsigned n, typename T, typename U>
- mln_sum_x(T,U)
+ mln_sum_product(T,U)
operator*(const vec<n,T>& lhs, const vec<n,U>& rhs);
// vec * s
@@ -400,6 +399,7 @@ namespace mln
vec<n,T>::vec(const vec<n, U>& rhs)
: super_()
{
+ mlc_converts_to(U, T)::check();
for (unsigned i = 0; i < n; ++i)
data_[i] = static_cast<T>(rhs[i]);
}
@@ -409,6 +409,7 @@ namespace mln
inline
vec<n,T>& vec<n,T>::operator=(const vec<n, U>& rhs)
{
+ mlc_converts_to(U, T)::check();
for (unsigned i = 0; i < n; ++i)
data_[i] = static_cast<T>(rhs[i]);
return *this;
@@ -515,11 +516,11 @@ namespace mln
template <unsigned n, typename T, typename U>
inline
- mln_sum_x(T,U)
+ mln_sum_product(T,U)
operator*(const vec<n,T>& lhs, const vec<n,U>& rhs)
{
- typedef mln_sum_x(T,U) R;
- mln_sum_x(T,U) tmp(literal::zero);
+ typedef mln_sum_product(T,U) R;
+ mln_sum_product(T,U) tmp(literal::zero);
for (unsigned i = 0; i < n; ++i)
tmp += lhs[i] * rhs[i];
return tmp;
diff --git a/milena/mln/fun/v2v/norm.hh b/milena/mln/fun/v2v/norm.hh
index 43a3f58..2dc4f2a 100644
--- a/milena/mln/fun/v2v/norm.hh
+++ b/milena/mln/fun/v2v/norm.hh
@@ -1,4 +1,5 @@
-// Copyright (C) 2007 EPITA Research and Development Laboratory
+// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory
+// (LRDE)
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -28,17 +29,15 @@
#ifndef MLN_FUN_V2V_NORM_HH
# define MLN_FUN_V2V_NORM_HH
-/*! \file mln/fun/v2v/norm.hh
- *
- * \brief Norm functors.
- *
- * \see mln/norm/.
- */
+/// \file mln/fun/v2v/norm.hh
+///
+/// Norm functors.
+///
+/// \see mln/norm/.
// FIXME: Move to mln/fun/x2v/?
# include <mln/core/concept/function.hh>
-# include <mln/trait/value_.hh>
# include <mln/norm/all.hh>
@@ -52,12 +51,11 @@ namespace mln
namespace v2v
{
- /*! \brief L1-norm.
- *
- * \c V is the type of input values; \c R is the result type.
- *
- * \see mln::norm::l1.
- */
+ /// L1-norm.
+ ///
+ /// \c V is the type of input values; \c R is the result type.
+ ///
+ /// \see mln::norm::l1.
template <typename V, typename R>
struct l1_norm : public Function_v2v< l1_norm<V, R> >
{
@@ -65,12 +63,11 @@ namespace mln
R operator()(const V& v) const;
};
- /*! \brief L2-norm.
- *
- * \c V is the type of input values; \c R is the result type.
- *
- * \see mln::norm::l2.
- */
+ /// L2-norm.
+ ///
+ /// \c V is the type of input values; \c R is the result type.
+ ///
+ /// \see mln::norm::l2.
template <typename V, typename R>
struct l2_norm : public Function_v2v< l2_norm<V, R> >
{
@@ -78,12 +75,11 @@ namespace mln
R operator()(const V& v) const;
};
- /*! \brief L-infty norm.
- *
- * \c V is the type of input values; \c R is the result type.
- *
- * \see mln::norm::linfty.
- */
+ /// L-infty norm.
+ ///
+ /// \c V is the type of input values; \c R is the result type.
+ ///
+ /// \see mln::norm::linfty.
template <typename V, typename R>
struct linfty_norm : public Function_v2v< linfty_norm<V, R> >
{
diff --git a/milena/mln/linear/ch_convolve.hh b/milena/mln/linear/ch_convolve.hh
index 59fb7e0..cb14372 100644
--- a/milena/mln/linear/ch_convolve.hh
+++ b/milena/mln/linear/ch_convolve.hh
@@ -64,14 +64,14 @@ namespace mln
typename I, typename W>
struct ch_convolve_helper
{
- typedef mln_sum_x(mln_value(I), mln_weight(W)) V;
+ typedef mln_sum_product(mln_value(I), mln_weight(W)) V;
typedef mln_ch_value(I, V) ret;
};
template <typename I, typename W>
struct ch_convolve_helper<false, I, W>
{
- typedef mln_sum_x(mln_value(I), W) V;
+ typedef mln_sum_product(mln_value(I), W) V;
typedef mln_ch_value(I, V) ret;
};
diff --git a/milena/mln/metal/array1d.hh b/milena/mln/metal/array1d.hh
index 7f441d8..d06f523 100644
--- a/milena/mln/metal/array1d.hh
+++ b/milena/mln/metal/array1d.hh
@@ -164,7 +164,7 @@ namespace mln
struct set_precise_binary_< op::times,
metal::array1d<T, n>, metal::array1d<U, n> >
{
- typedef mln_sum_x(T,U) ret;
+ typedef mln_sum_product(T,U) ret;
};
template < template <class, class> class Name,
diff --git a/milena/mln/metal/array2d.hh b/milena/mln/metal/array2d.hh
index 4f3992a..66f0cb9 100644
--- a/milena/mln/metal/array2d.hh
+++ b/milena/mln/metal/array2d.hh
@@ -175,7 +175,7 @@ namespace mln
struct set_precise_binary_< op::times,
metal::array2d<T, r, c>, metal::array2d<U, r, c> >
{
- typedef mln_sum_x(T,U) ret;
+ typedef mln_sum_product(T,U) ret;
};
template < template <class, class> class Name,
diff --git a/milena/mln/metal/array3d.hh b/milena/mln/metal/array3d.hh
index 574d2a6..9df11fe 100644
--- a/milena/mln/metal/array3d.hh
+++ b/milena/mln/metal/array3d.hh
@@ -176,7 +176,7 @@ namespace mln
struct set_precise_binary_< op::times,
metal::array3d<T, s, r, c>, metal::array3d<U, s, r, c> >
{
- typedef mln_sum_x(T,U) ret;
+ typedef mln_sum_product(T,U) ret;
};
template < template <class, class> class Name,
diff --git a/milena/mln/metal/mat.hh b/milena/mln/metal/mat.hh
index 1affc19..9690891 100644
--- a/milena/mln/metal/mat.hh
+++ b/milena/mln/metal/mat.hh
@@ -153,13 +153,13 @@ namespace mln
unsigned m, typename U >
struct set_precise_binary_< op::times, metal::mat<n,o,T>, metal::mat<o,m,U> >
{
- typedef metal::mat<n, m, mln_sum_x(T, U)> ret;
+ typedef metal::mat<n, m, mln_sum_product(T, U)> ret;
};
template < unsigned n, typename T, typename U >
struct set_precise_binary_< op::times, metal::mat<n,n,T>, metal::mat<n,n,U> >
{ // Disambiguate between both previous defs.
- typedef metal::mat<n, n, mln_sum_x(T, U)> ret;
+ typedef metal::mat<n, n, mln_sum_product(T, U)> ret;
};
// mat * vec
@@ -168,7 +168,7 @@ namespace mln
typename U >
struct set_precise_binary_< op::times, metal::mat<n,m,T>, metal::vec<m,U> >
{
- typedef metal::vec<n, mln_sum_x(T, U)> ret;
+ typedef metal::vec<n, mln_sum_product(T, U)> ret;
};
// mat * s
@@ -226,14 +226,14 @@ namespace mln
template <unsigned n, unsigned o, typename T,
unsigned m, typename U>
- mat<n, m, mln_sum_x(T,U)>
+ mat<n, m, mln_sum_product(T,U)>
operator*(const mat<n,o,T>& lhs, const mat<o,m,U>& rhs);
// mat * vec
template <unsigned n, unsigned m, typename T,
typename U>
- vec<n, mln_sum_x(T,U)>
+ vec<n, mln_sum_product(T,U)>
operator*(const mat<n,m,T>& lhs, const vec<m,U>& rhs);
// mat * s
@@ -401,10 +401,10 @@ namespace mln
template <unsigned n, unsigned o, typename T,
unsigned m, typename U>
inline
- mat<n, m, mln_sum_x(T,U)>
+ mat<n, m, mln_sum_product(T,U)>
operator*(const mat<n,o,T>& lhs, const mat<o,m,U>& rhs)
{
- mat<n,m, mln_sum_x(T,U)> tmp;
+ mat<n,m, mln_sum_product(T,U)> tmp;
for (unsigned i = 0; i < n; ++i)
for (unsigned j = 0; j < m; ++j)
{
@@ -418,13 +418,13 @@ namespace mln
template <unsigned n, unsigned m, typename T,
typename U>
inline
- vec<n, mln_sum_x(T,U)>
+ vec<n, mln_sum_product(T,U)>
operator*(const mat<n,m,T>& lhs, const vec<m,U>& rhs)
{
- vec<n, mln_sum_x(T,U)> tmp;
+ vec<n, mln_sum_product(T,U)> tmp;
for (unsigned i = 0; i < n; ++i)
{
- mln_sum_x(T,U) sum(literal::zero);
+ mln_sum_product(T,U) sum(literal::zero);
for (unsigned j = 0; j < m; ++j)
sum += lhs(i, j) * rhs[j];
tmp[i] = sum;
diff --git a/milena/mln/metal/vec.hh b/milena/mln/metal/vec.hh
index 36f00ab..840eda6 100644
--- a/milena/mln/metal/vec.hh
+++ b/milena/mln/metal/vec.hh
@@ -248,7 +248,7 @@ namespace mln
struct set_precise_binary_< op::times,
metal::vec<n, T>, metal::vec<n, U> >
{
- typedef mln_sum_x(T,U) ret;
+ typedef mln_sum_product(T,U) ret;
};
template < template <class, class> class Name,
@@ -299,7 +299,7 @@ namespace mln
// vec * vec
template <unsigned n, typename T, typename U>
- mln_sum_x(T,U)
+ mln_sum_product(T,U)
operator*(const vec<n,T>& lhs, const vec<n,U>& rhs);
// vec * s
@@ -481,10 +481,10 @@ namespace mln
template <unsigned n, typename T, typename U>
inline
- mln_sum_x(T,U)
+ mln_sum_product(T,U)
operator*(const vec<n,T>& lhs, const vec<n,U>& rhs)
{
- mln_sum_x(T,U) tmp(literal::zero);
+ mln_sum_product(T,U) tmp(literal::zero);
for (unsigned i = 0; i < n; ++i)
tmp += lhs[i] * rhs[i];
return tmp;
diff --git a/milena/mln/norm/l1.hh b/milena/mln/norm/l1.hh
index c400eb6..e702d7a 100644
--- a/milena/mln/norm/l1.hh
+++ b/milena/mln/norm/l1.hh
@@ -31,15 +31,12 @@
/// \file mln/norm/l1.hh
///
-/// \brief Define some L1-norm related routines.
-/// \see http://mathworld.wolfram.com/L1-Norm.html for more information.
+/// Define some L1-norm related routines.
+/// \see http://mathworld.wolfram.com/L1-Norm.html for more information.
# include <mln/math/abs.hh>
# include <mln/algebra/vec.hh>
-// FIXME: Use mln_sum_x (to be renamed as mln_sum_product) instead of
-// mln_sum.
-
namespace mln
{
@@ -50,19 +47,19 @@ namespace mln
/// L1-norm of a vector \a vec.
/// \{
template <unsigned n, typename C>
- mln_sum(C) l1(const C (&vec)[n]);
+ mln_sum_product(C,C) l1(const C (&vec)[n]);
template <unsigned n, typename C>
- mln_sum(C) l1(const algebra::vec<n,C>& vec);
+ mln_sum_product(C,C) l1(const algebra::vec<n,C>& vec);
/// \}
/// L1-norm distance between vectors \a vec1 and \a vec2.
/// \{
template <unsigned n, typename C>
- mln_sum(C) l1_distance(const C (&vec1)[n], const C (&vec2)[n]);
+ mln_sum_product(C,C) l1_distance(const C (&vec1)[n], const C (&vec2)[n]);
template <unsigned n, typename C>
- mln_sum(C) l1_distance(const algebra::vec<n,C>& vec1,
+ mln_sum_product(C,C) l1_distance(const algebra::vec<n,C>& vec1,
const algebra::vec<n,C>& vec2);
/// \}
@@ -73,10 +70,10 @@ namespace mln
{
template <unsigned n, typename C, typename V>
inline
- mln_sum(C)
+ mln_sum_product(C,C)
l1_(const V& vec)
{
- typedef mln_sum(C) M;
+ typedef mln_sum_product(C,C) M;
M m = 0;
for (unsigned i = 0; i < n; ++i)
{
@@ -88,10 +85,10 @@ namespace mln
template <unsigned n, typename C, typename V>
inline
- mln_sum(C)
+ mln_sum_product(C,C)
l1_distance_(const V& vec1, const V& vec2)
{
- typedef mln_sum(C) D;
+ typedef mln_sum_product(C,C) D;
D d = 0;
for (unsigned i = 0; i < n; ++i)
{
@@ -110,7 +107,7 @@ namespace mln
template <unsigned n, typename C>
inline
- mln_sum(C)
+ mln_sum_product(C,C)
l1(const C (&vec)[n])
{
return impl::l1_<n, C>(vec);
@@ -118,7 +115,7 @@ namespace mln
template <unsigned n, typename C>
inline
- mln_sum(C)
+ mln_sum_product(C,C)
l1(const algebra::vec<n,C>& vec)
{
return impl::l1_<n, C>(vec);
@@ -126,7 +123,7 @@ namespace mln
template <unsigned n, typename C>
inline
- mln_sum(C)
+ mln_sum_product(C,C)
l1_distance(const C (&vec1)[n], const C (&vec2)[n])
{
return impl::l1_distance_<n, C>(vec1, vec2);
@@ -134,7 +131,7 @@ namespace mln
template <unsigned n, typename C>
inline
- mln_sum(C)
+ mln_sum_product(C,C)
l1_distance(const algebra::vec<n,C>& vec1, const algebra::vec<n,C>& vec2)
{
return impl::l1_distance_<n, C>(vec1, vec2);
diff --git a/milena/mln/norm/l2.hh b/milena/mln/norm/l2.hh
index 03e1142..420a1f0 100644
--- a/milena/mln/norm/l2.hh
+++ b/milena/mln/norm/l2.hh
@@ -38,11 +38,9 @@
# include <mln/math/sqr.hh>
# include <mln/math/sqrt.hh>
# include <mln/algebra/vec.hh>
+# include <mln/value/ops.hh>
-// FIXME: Use mln_sum_x (to be renamed as mln_sum_product) instead of
-// mln_sum.
-
namespace mln
{
@@ -59,28 +57,28 @@ namespace mln
/// L2-norm of a vector \a vec.
/// \{
template <unsigned n, typename C>
- mln_sum(C) l2(const C (&vec)[n]);
+ mln_sum_product(C,C) l2(const C (&vec)[n]);
template <unsigned n, typename C>
- mln_sum(C) l2(const algebra::vec<n,C>& vec);
+ mln_sum_product(C,C) l2(const algebra::vec<n,C>& vec);
/// \}
/// Squared L2-norm of a vector \a vec.
/// \{
template <unsigned n, typename C>
- mln_sum(C) sqr_l2(const C (&vec)[n]);
+ mln_sum_product(C,C) sqr_l2(const C (&vec)[n]);
template <unsigned n, typename C>
- mln_sum(C) sqr_l2(const algebra::vec<n,C>& vec);
+ mln_sum_product(C,C) sqr_l2(const algebra::vec<n,C>& vec);
/// \}
/// L2-norm distance between vectors \a vec1 and \p vec2.
/// \{
template <unsigned n, typename C>
- mln_sum(C) l2_distance(const C (&vec1)[n], const C (&vec2)[n]);
+ mln_sum_product(C,C) l2_distance(const C (&vec1)[n], const C (&vec2)[n]);
template <unsigned n, typename C>
- mln_sum(C) l2_distance(const algebra::vec<n,C>& vec1,
+ mln_sum_product(C,C) l2_distance(const algebra::vec<n,C>& vec1,
const algebra::vec<n,C>& vec2);
/// \}
@@ -89,13 +87,13 @@ namespace mln
namespace impl
{
-
+
template <unsigned n, typename C, typename V>
inline
- mln_sum(C)
+ mln_sum_product(C,C)
l2_(const V& vec)
{
- typedef mln_sum(C) M;
+ typedef mln_sum_product(C,C) M;
M m = 0;
for (unsigned i = 0; i < n; ++i)
{
@@ -107,10 +105,10 @@ namespace mln
template <unsigned n, typename C, typename V>
inline
- mln_sum(C)
+ mln_sum_product(C,C)
sqr_l2_(const V& vec)
{
- mln_sum(C) m = 0;
+ mln_sum_product(C,C) m = 0;
for (unsigned i = 0; i < n; ++i)
m += mln::math::sqr(vec[i]);
return m;
@@ -118,10 +116,10 @@ namespace mln
template <unsigned n, typename C, typename V>
inline
- mln_sum(C)
+ mln_sum_product(C,C)
l2_distance_(const V& vec1, const V& vec2)
{
- typedef mln_sum(C) D;
+ typedef mln_sum_product(C,C) D;
D d = 0;
for (unsigned i = 0; i < n; ++i)
{
@@ -140,7 +138,7 @@ namespace mln
template <unsigned n, typename C>
inline
- mln_sum(C)
+ mln_sum_product(C,C)
l2(const C (&vec)[n])
{
return impl::l2_<n, C>(vec);
@@ -148,7 +146,7 @@ namespace mln
template <unsigned n, typename C>
inline
- mln_sum(C)
+ mln_sum_product(C,C)
l2(const algebra::vec<n,C>& vec)
{
return impl::l2_<n, C>(vec);
@@ -157,7 +155,7 @@ namespace mln
template <unsigned n, typename C>
inline
- mln_sum(C)
+ mln_sum_product(C,C)
sqr_l2(const C (&vec)[n])
{
return impl::sqr_l2_<n, C>(vec);
@@ -165,7 +163,7 @@ namespace mln
template <unsigned n, typename C>
inline
- mln_sum(C)
+ mln_sum_product(C,C)
sqr_l2(const algebra::vec<n,C>& vec)
{
return impl::sqr_l2_<n, C>(vec);
@@ -174,7 +172,7 @@ namespace mln
template <unsigned n, typename C>
inline
- mln_sum(C)
+ mln_sum_product(C,C)
l2_distance(const C (&vec1)[n], const C (&vec2)[n])
{
return impl::l2_distance_<n, C>(vec1, vec2);
@@ -182,7 +180,7 @@ namespace mln
template <unsigned n, typename C>
inline
- mln_sum(C)
+ mln_sum_product(C,C)
l2_distance(const algebra::vec<n,C>& vec1, const algebra::vec<n,C>& vec2)
{
return impl::l2_distance_<n, C>(vec1, vec2);
diff --git a/milena/mln/value/ops.hh b/milena/mln/value/ops.hh
index 0bb7fe3..37f8a6b 100644
--- a/milena/mln/value/ops.hh
+++ b/milena/mln/value/ops.hh
@@ -44,11 +44,11 @@
# include <mln/metal/ret.hh>
/// Type trait for value sum.
-# define mln_trait_value_sum_x(T, U) \
+# define mln_trait_value_sum_product(T, U) \
typename mln::trait::value_< mln_trait_op_times(T,U) >::sum
/// Shortcut for type trait for value sum.
-# define mln_sum_x(T, U) mln_trait_value_sum_x(T, U)
+# define mln_sum_product(T, U) mln_trait_value_sum_product(T, U)
// FIXME: In the definitions below, is that equiv or interop?
--
1.5.6.5
1
0
https://svn.lrde.epita.fr/svn/oln/trunk/milena
Index: ChangeLog
from Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
Fix warnings due to g++ -Wconversion option.
* mln/value/proxy.hh,
* mln/value/cast.hh,
* mln/value/ops.hh,
* mln/fun/v2v/linear.hh,
* mln/io/fits/load.hh,
* tests/value/float01.cc,
* tests/value/Makefile.am,
* tests/win/cuboid3d.cc,
* tests/win/vline2d.cc,
* tests/win/cube3d.cc,
* tests/win/backdiag2d.cc,
* tests/win/octagon2d.cc,
* tests/win/disk2d.cc,
* tests/win/hline2d.cc,
* tests/win/segment1d.cc,
* tests/win/rectangle2d.cc: Fix warning with Wconversion.
Upgrade file doc style.
Layout.
* mln/value/float01_.hh: Likewise.
(mln_card): Replace by...
(mln_max): ...this. So work for n > 12.
* tests/value/quat.cc: Move in...
* tests/algebra/quat.cc: ...here; where it belongs!
* tests/algebra/Makefile.am: Update.
mln/fun/v2v/linear.hh | 2 +-
mln/io/fits/load.hh | 6 ++++--
mln/value/cast.hh | 2 +-
mln/value/float01_.hh | 16 ++++++++--------
mln/value/ops.hh | 3 ++-
mln/value/proxy.hh | 7 +++----
tests/algebra/Makefile.am | 2 ++
tests/algebra/quat.cc | 14 +++++++-------
tests/value/Makefile.am | 2 --
tests/value/float01.cc | 42 ++++++++++++++++++++++--------------------
tests/win/backdiag2d.cc | 26 ++++++++++++--------------
tests/win/cube3d.cc | 24 +++++++++++-------------
tests/win/cuboid3d.cc | 24 +++++++++++-------------
tests/win/disk2d.cc | 27 ++++++++++++---------------
tests/win/hline2d.cc | 24 +++++++++++-------------
tests/win/octagon2d.cc | 28 +++++++++++++---------------
tests/win/rectangle2d.cc | 20 +++++++++-----------
tests/win/segment1d.cc | 20 +++++++++-----------
tests/win/vline2d.cc | 24 +++++++++++-------------
19 files changed, 149 insertions(+), 164 deletions(-)
Index: mln/value/proxy.hh
--- mln/value/proxy.hh (revision 3113)
+++ mln/value/proxy.hh (working copy)
@@ -29,10 +29,9 @@
#ifndef MLN_VALUE_PROXY_HH
# define MLN_VALUE_PROXY_HH
-/*! \file mln/value/proxy.hh
- *
- * \brief Define a generic proxy class for an image pixel value.
- */
+/// \file mln/value/proxy.hh
+///
+/// Define a generic proxy class for an image pixel value.
# include <mln/core/concept/value.hh>
# include <mln/trait/value_.hh>
Index: mln/value/cast.hh
--- mln/value/cast.hh (revision 3113)
+++ mln/value/cast.hh (working copy)
@@ -88,7 +88,7 @@
{
// FIXME: Add static_cast<Dest>?
// FIXME: Add exact()?
- return internal::cast_(&src, src);
+ return static_cast<Dest>(internal::cast_(&src, src));
}
# endif // ! MLN_INCLUDE_ONLY
Index: mln/value/ops.hh
--- mln/value/ops.hh (revision 3113)
+++ mln/value/ops.hh (working copy)
@@ -243,7 +243,8 @@
mln_trait_op_div(Vl, Vr)
operator / (const value::Scalar<Vl>& lhs, const value::Scalar<Vr>& rhs)
{
- return value::equiv(lhs) / value::equiv(rhs);
+ typedef mln_trait_op_div(Vl, Vr) R;
+ return static_cast<R>(value::equiv(lhs)) / static_cast<R>(value::equiv(rhs));
}
template <typename Vl, typename Vr>
Index: mln/value/float01_.hh
--- mln/value/float01_.hh (revision 3113)
+++ mln/value/float01_.hh (working copy)
@@ -167,9 +167,9 @@
inline
float01_<n>::float01_(float val)
{
- mln_precondition(val >= 0);
- mln_precondition(val <= 1);
- this->v_ = static_cast<enc_>(val * (mln_card(float01_<n>) - 1)); // FIXME
+ mln_precondition(val >= 0.f);
+ mln_precondition(val <= 1.f);
+ this->v_ = static_cast<enc_>(val * (float(mln_max(enc_)) - 1.f)); // FIXME
}
template <unsigned n>
@@ -177,7 +177,7 @@
float
float01_<n>::value() const
{
- return float(this->v_) / float(mln_card(float01_<n>) - 1); // FIXME
+ return float(this->v_) / (float(mln_max(enc_)) - 1.f); // FIXME
}
template <unsigned n>
@@ -193,9 +193,9 @@
float01_<n>&
float01_<n>::operator=(float val)
{
- mln_precondition(val >= 0);
- mln_precondition(val <= 1);
- this->v_ = static_cast<enc_>(val * (mln_card(float01_<n>) - 1)); // FIXME
+ mln_precondition(val >= 0.f);
+ mln_precondition(val <= 1.f);
+ this->v_ = static_cast<enc_>(val * (float(mln_max(enc_)) - 1.f)); // FIXME
return *this;
}
@@ -203,7 +203,7 @@
inline
float01_<n>::operator float() const
{
- return float(this->v_) / float(mln_card(float01_<n>) - 1);
+ return float(this->v_) / (float(mln_max(enc_)) - 1.f);
}
Index: mln/fun/v2v/linear.hh
--- mln/fun/v2v/linear.hh (revision 3113)
+++ mln/fun/v2v/linear.hh (working copy)
@@ -84,7 +84,7 @@
R
linear<V,T,R>::operator()(const V& v) const
{
- return convert::to<R>(a * static_cast<T>(v) + b);
+ return mln::convert::to<R>(a * static_cast<T>(v) + b);
}
template <typename V, typename T, typename R>
Index: mln/io/fits/load.hh
--- mln/io/fits/load.hh (revision 3113)
+++ mln/io/fits/load.hh (working copy)
@@ -1,5 +1,5 @@
// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 EPITA
-// Research and Development Laboratory
+// 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
@@ -44,6 +44,7 @@
//FIXME: Add fitsio dependency
# include <fitsio.h>
+
namespace mln
{
@@ -98,7 +99,8 @@
if (fits_open_file(&fptr, filename.c_str(), READONLY, &status))
fits_exit(status);
- if (fits_read_keys_lng(fptr, "NAXIS", 1, 2, naxes, &nfound, &status))
+ char NAXIS[] = "NAXIS";
+ if (fits_read_keys_lng(fptr, NAXIS, 1, 2, naxes, &nfound, &status))
fits_exit(status);
const int ncols = naxes[0], nrows = naxes[1];
Index: tests/value/float01.cc
--- tests/value/float01.cc (revision 3113)
+++ tests/value/float01.cc (working copy)
@@ -1,4 +1,5 @@
// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory
+// (LRDE)
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -25,10 +26,9 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-/*! \file tests/value/float01.cc
- *
- * \brief Tests on mln::value::float01.
- */
+/// \file tests/value/float01.cc
+///
+/// Tests on mln::value::float01.
#include <iostream>
@@ -53,20 +53,20 @@
using namespace mln::value;
using mln::value::int_u8;
-float fi(int) { return 0.5; }
+float fi(int) { return 0.5f; }
int ii(int) { return 1; }
-float fd(double) { return 0.5; }
+float fd(double) { return 0.5f; }
int id(double) { return 1; }
struct tofloat01 : mln::Function_v2v<tofloat01>
{
- typedef float01_<16> result;
+ typedef float01_<12> result;
result operator()(int_u8 v) const
{
- result ret(double(v) / (mln_max(int_u8)));
+ result ret = static_cast<float>(v) / static_cast<float>(mln_max(int_u8));
// std::cout << v << "-> " << ret << std::endl;
return ret;
}
@@ -76,9 +76,9 @@
{
typedef int_u8 result;
- result operator()(float01_<16> v) const
+ result operator()(float01_<12> v) const
{
- result ret = int(v.value() * 255);
+ result ret = static_cast<int>(v.value() * 255);
// FIXME: Dead code.
//std::cout << v << "-> " << ret << std::endl;
return ret;
@@ -96,13 +96,13 @@
assert(approx_equal(b,a));
std::cout << b << std::endl;
- b = b + 0.2;
+ b = b + 0.2f;
std::cout << b << std::endl;
- b = b - 0.2;
+ b = b - 0.2f;
std::cout << b << std::endl;
- b = b * 1.5;
+ b = b * 1.5f;
std::cout << b << std::endl;
- b = b / 4.6;
+ b = b / 4.6f;
std::cout << b << std::endl;
b = b / 3;
@@ -110,14 +110,14 @@
b = b * 1;
std::cout << b << std::endl;
- a = fi(a);
- a = ii(a);
+ a = fi( static_cast<int>(a) );
+ a = static_cast<float>( ii( static_cast<int>(a) ) );
a = fd(a);
- a = id(a);
+ a = static_cast<float>( id(a) );
b = a;
a = b;
- b = 0.34;
+ b = 0.34f;
std::cout << b << std::endl;
b = 0;
std::cout << b << std::endl;
@@ -125,13 +125,15 @@
std::cout << b << std::endl;
{
+ typedef value::float01_<12> float01_12;
+
std::cout << "convert" << std::endl;
image2d<int_u8>
lena = io::pgm::load<int_u8>("../img/lena.pgm"),
ref(lena.domain());
- image2d<float01_16> out(lena.domain());
- image2d<float01_16> tmp(lena.domain());
+ image2d<float01_12> out(lena.domain());
+ image2d<float01_12> tmp(lena.domain());
tmp = level::transform(lena, tofloat01());
Index: tests/value/Makefile.am
--- tests/value/Makefile.am (revision 3113)
+++ tests/value/Makefile.am (working copy)
@@ -19,7 +19,6 @@
int_u8 \
interop \
label \
- quat \
rgb8 \
scalar \
set \
@@ -49,7 +48,6 @@
int_s16_SOURCES = int_s16.cc
int_u8_SOURCES = int_u8.cc
label_SOURCES = label.cc
-quat_SOURCES = quat.cc
rgb8_SOURCES = rgb8.cc
scalar_SOURCES = scalar.cc
set_SOURCES = set.cc
Index: tests/win/cuboid3d.cc
--- tests/win/cuboid3d.cc (revision 3113)
+++ tests/win/cuboid3d.cc (working copy)
@@ -1,4 +1,4 @@
-// Copyright (C) 2008 EPITA Research and Development Laboratory
+// 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
@@ -25,19 +25,18 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-/*! \file tests/win/cuboid3d.cc
- *
- * \brief Tests on mln::win::cuboid3d.
- */
+/// \file tests/win/cuboid3d.cc
+///
+/// Tests on mln::win::cuboid3d.
#include <cmath>
+
#include <mln/win/cuboid3d.hh>
#include <mln/win/sym.hh>
-
#include <mln/convert/to_image.hh>
-
#include <mln/debug/println.hh>
+
int main()
{
using namespace mln;
@@ -52,16 +51,15 @@
mln_assertion(cuboid.delta() == 3);
- for (int s = -7; s <= 7; ++s)
- for (int x = -7; x <= 7; ++x)
- for (int y = -7; y <= 7; ++y)
+ for (def::coord s = -7; s <= 7; ++s)
+ for (def::coord x = -7; x <= 7; ++x)
+ for (def::coord y = -7; y <= 7; ++y)
{
- mln_assertion(((abs(s) <= 3 && abs(x) <= 1 && abs(y) <= 2)) ||
+ mln_assertion((std::abs(s) <= 3 && std::abs(x) <= 1 && std::abs(y) <= 2) ||
!cuboid.has(dpoint3d(s, x, y)));
- mln_assertion((abs(s) <= 3 && abs(x) <= 1 && abs(y) <= 2) ==
+ mln_assertion((std::abs(s) <= 3 && std::abs(x) <= 1 && std::abs(y) <= 2) ==
(cuboid.has(dpoint3d(s, x, y))));
}
debug::println(convert::to_image(cuboid));
}
-
Index: tests/win/vline2d.cc
--- tests/win/vline2d.cc (revision 3113)
+++ tests/win/vline2d.cc (working copy)
@@ -1,4 +1,5 @@
-// Copyright (C) 2007 EPITA Research and Development Laboratory
+// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory
+// (LRDE)
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -25,19 +26,17 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-/*! \file tests/win/vline2d.cc
- *
- * \brief Tests on mln::win::vline2d.
- */
+/// \file tests/win/vline2d.cc
+///
+/// Tests on mln::win::vline2d.
#include <cmath>
#include <mln/win/vline2d.hh>
-
#include <mln/convert/to_image.hh>
-
#include <mln/debug/println.hh>
+
int main()
{
using namespace mln;
@@ -47,15 +46,14 @@
mln_assertion(vline.delta() == 2);
- for (int x = -5; x <= 5; ++x)
- for (int y = -5; y <= 5; ++y)
+ for (def::coord x = -5; x <= 5; ++x)
+ for (def::coord y = -5; y <= 5; ++y)
{
- mln_assertion(((abs(x) <= 2) && (abs(y) <= 2)) ||
+ mln_assertion((std::abs(x) <= 2 && std::abs(y) <= 2) ||
!vline.has(dpoint2d(x, y)));
- mln_assertion((0 == y) == (vline.has(dpoint2d(x, y))) ||
- abs(x) > 2);
+ mln_assertion((0 == y) == vline.has(dpoint2d(x, y)) ||
+ std::abs(x) > 2);
}
debug::println(convert::to_image(vline));
}
-
Index: tests/win/cube3d.cc
--- tests/win/cube3d.cc (revision 3113)
+++ tests/win/cube3d.cc (working copy)
@@ -1,4 +1,5 @@
-// Copyright (C) 2007 EPITA Research and Development Laboratory
+// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory
+// (LRDE)
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -25,19 +26,17 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-/*! \file tests/win/cube3d.cc
- *
- * \brief Tests on mln::win::cube3d.
- */
+/// \file tests/win/cube3d.cc
+///
+/// Tests on mln::win::cube3d.
#include <cmath>
#include <mln/win/cube3d.hh>
-
#include <mln/convert/to_image.hh>
-
#include <mln/debug/println.hh>
+
int main()
{
using namespace mln;
@@ -47,16 +46,15 @@
mln_assertion(cube.delta() == 2);
- for (int s = -5; s <= 5; ++s)
- for (int x = -5; x <= 5; ++x)
- for (int y = -5; y <= 5; ++y)
+ for (def::coord s = -5; s <= 5; ++s)
+ for (def::coord x = -5; x <= 5; ++x)
+ for (def::coord y = -5; y <= 5; ++y)
{
- mln_assertion(((abs(x) <= 2) && (abs(y) <= 2) && (abs(s) <= 2)) ||
+ mln_assertion((std::abs(x) <= 2 && std::abs(y) <= 2 && std::abs(s) <= 2) ||
!cube.has(dpoint3d(s, y, x)));
- mln_assertion((abs(x) <= 2 && abs(y) <= 2 && abs(s) <= 2) ==
+ mln_assertion((std::abs(x) <= 2 && std::abs(y) <= 2 && std::abs(s) <= 2) ==
(cube.has(dpoint3d(s, y, x))));
}
debug::println(convert::to_image(cube));
}
-
Index: tests/win/backdiag2d.cc
--- tests/win/backdiag2d.cc (revision 3113)
+++ tests/win/backdiag2d.cc (working copy)
@@ -1,4 +1,5 @@
-// Copyright (C) 2007 EPITA Research and Development Laboratory
+// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory
+// (LRDE)
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -25,19 +26,17 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-/*! \file tests/win/backdiag2d.cc
- *
- * \brief Tests on mln::win::backdiag2d.
- */
+/// \file tests/win/backdiag2d.cc
+///
+/// Tests on mln::win::backdiag2d.
#include <cmath>
#include <mln/win/backdiag2d.hh>
-
#include <mln/convert/to_image.hh>
-
#include <mln/debug/println.hh>
+
int main()
{
using namespace mln;
@@ -47,16 +46,15 @@
mln_assertion(diag.delta() == 4);
- for (int x = -5; x <= 5; ++x)
- for (int y = -5; y <= 5; ++y)
+ for (def::coord x = -5; x <= 5; ++x)
+ for (def::coord y = -5; y <= 5; ++y)
{
- mln_assertion(((abs(x) <= 4) && (abs(y) <= 4)) ||
+ mln_assertion((std::abs(x) <= 4 && std::abs(y) <= 4) ||
!diag.has(dpoint2d(y, x)));
- mln_assertion((x == y) == (diag.has(dpoint2d(x, y))) ||
- abs(x) > 4 ||
- abs(y) > 4);
+ mln_assertion((x == y) == diag.has(dpoint2d(x, y)) ||
+ std::abs(x) > 4 ||
+ std::abs(y) > 4);
}
debug::println(convert::to_image(diag));
}
-
Index: tests/win/disk2d.cc
--- tests/win/disk2d.cc (revision 3113)
+++ tests/win/disk2d.cc (working copy)
@@ -1,4 +1,5 @@
-// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory
+// (LRDE)
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -25,19 +26,17 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-/*! \file tests/win/disk2d.cc
- *
- * \brief Tests on mln::win::disk2d.
- */
+/// \file tests/win/disk2d.cc
+///
+/// Tests on mln::win::disk2d.
#include <cmath>
#include <mln/win/disk2d.hh>
-
#include <mln/convert/to_image.hh>
-
#include <mln/debug/println.hh>
+
int main()
{
using namespace mln;
@@ -48,17 +47,15 @@
mln_assertion(disk.delta() == 27);
- for (int x = -30; x <= 30; ++x)
- for (int y = -30; y <= 30; ++y)
+ for (def::coord x = -30; x <= 30; ++x)
+ for (def::coord y = -30; y <= 30; ++y)
{
- mln_assertion(((abs(x) <= 27) && (abs(y) <= 27)) ||
+ mln_assertion((std::abs(x) <= 27 && std::abs(y) <= 27) ||
!disk.has(dpoint2d(y, x)));
- mln_assertion(((x * x + y * y) <= static_cast<int>(l2)) ==
- (disk.has(dpoint2d(x, y))) ||
- abs(x) > 27 ||
- abs(y) > 27);
+ mln_assertion(((x * x + y * y) <= static_cast<int>(l2)) == disk.has(dpoint2d(x, y)) ||
+ std::abs(x) > 27 ||
+ std::abs(y) > 27);
}
debug::println(convert::to_image(disk));
}
-
Index: tests/win/octagon2d.cc
--- tests/win/octagon2d.cc (revision 3113)
+++ tests/win/octagon2d.cc (working copy)
@@ -1,4 +1,5 @@
-// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory
+// (LRDE)
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -25,19 +26,17 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-/*! \file tests/win/octagon2d.cc
- *
- * \brief Tests on mln::win::octagon2d.
- */
+/// \file tests/win/octagon2d.cc
+///
+/// Tests on mln::win::octagon2d.
#include <cmath>
#include <mln/win/octagon2d.hh>
-
#include <mln/convert/to_image.hh>
-
#include <mln/debug/println.hh>
+
int main()
{
using namespace mln;
@@ -47,17 +46,16 @@
mln_assertion(oct.delta() == 6);
- for (int x = -16; x <= 16; ++x)
- for (int y = -16; y <= 16; ++y)
+ for (def::coord x = -16; x <= 16; ++x)
+ for (def::coord y = -16; y <= 16; ++y)
{
- mln_assertion(((abs(x) <= 6) && (abs(y) <= 6)) ||
+ mln_assertion((std::abs(x) <= 6 && std::abs(y) <= 6) ||
!oct.has(dpoint2d(x, y)));
- mln_assertion((abs(x) + abs(y) <= static_cast<int>(l / 2 + l / 6)) ==
- (oct.has(dpoint2d(x, y))) ||
- abs(x) > 2 ||
- abs(y) > 2);
+ mln_assertion((std::abs(x) + std::abs(y) <= static_cast<int>(l / 2 + l / 6)) ==
+ oct.has(dpoint2d(x, y)) ||
+ std::abs(x) > 2 ||
+ std::abs(y) > 2);
}
debug::println(convert::to_image(oct));
}
-
Index: tests/win/hline2d.cc
--- tests/win/hline2d.cc (revision 3113)
+++ tests/win/hline2d.cc (working copy)
@@ -1,4 +1,5 @@
-// Copyright (C) 2007 EPITA Research and Development Laboratory
+// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory
+// (LRDE)
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -25,19 +26,17 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-/*! \file tests/win/hline2d.cc
- *
- * \brief Tests on mln::win::hline2d.
- */
+/// \file tests/win/hline2d.cc
+///
+/// Tests on mln::win::hline2d.
#include <cmath>
#include <mln/win/hline2d.hh>
-
#include <mln/convert/to_image.hh>
-
#include <mln/debug/println.hh>
+
int main()
{
using namespace mln;
@@ -47,15 +46,14 @@
mln_assertion(hline.delta() == 2);
- for (int x = -5; x <= 5; ++x)
- for (int y = -5; y <= 5; ++y)
+ for (def::coord x = -5; x <= 5; ++x)
+ for (def::coord y = -5; y <= 5; ++y)
{
- mln_assertion(((abs(x) <= 2) && (abs(y) <= 2)) ||
+ mln_assertion((std::abs(x) <= 2 && std::abs(y) <= 2) ||
!hline.has(dpoint2d(x, y)));
- mln_assertion((0 == x) == (hline.has(dpoint2d(x, y))) ||
- abs(y) > 2);
+ mln_assertion((x == 0) == (hline.has(dpoint2d(x, y))) ||
+ std::abs(y) > 2);
}
debug::println(convert::to_image(hline));
}
-
Index: tests/win/segment1d.cc
--- tests/win/segment1d.cc (revision 3113)
+++ tests/win/segment1d.cc (working copy)
@@ -1,4 +1,5 @@
-// Copyright (C) 2007 EPITA Research and Development Laboratory
+// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory
+// (LRDE)
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -25,19 +26,17 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-/*! \file tests/win/segment1d.cc
- *
- * \brief Tests on mln::win::segment1d.
- */
+/// \file tests/win/segment1d.cc
+///
+/// Tests on mln::win::segment1d.
#include <cmath>
#include <mln/win/segment1d.hh>
-
#include <mln/convert/to_image.hh>
-
#include <mln/debug/println.hh>
+
int main()
{
using namespace mln;
@@ -47,12 +46,11 @@
mln_assertion(segm.delta() == 2);
- for (int x = -5; x <= 5; ++x)
+ for (def::coord x = -5; x <= 5; ++x)
{
- mln_assertion((abs(x) <= 2) || !segm.has(dpoint1d(x)));
- mln_assertion((abs(x) <= 2) == (segm.has(dpoint1d(x))));
+ mln_assertion(std::abs(x) <= 2 || ! segm.has(dpoint1d(x)));
+ mln_assertion((std::abs(x) <= 2) == segm.has(dpoint1d(x)));
}
debug::println(convert::to_image(segm));
}
-
Index: tests/win/rectangle2d.cc
--- tests/win/rectangle2d.cc (revision 3113)
+++ tests/win/rectangle2d.cc (working copy)
@@ -1,4 +1,5 @@
-// Copyright (C) 2007 EPITA Research and Development Laboratory
+// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory
+// (LRDE)
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -25,17 +26,15 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-/*! \file tests/win/rectangle2d.cc
- *
- * \brief Tests on mln::win::rectangle2d.
- */
+/// \file tests/win/rectangle2d.cc
+///
+/// Tests on mln::win::rectangle2d.
#include <cmath>
+
#include <mln/win/rectangle2d.hh>
#include <mln/win/sym.hh>
-
#include <mln/convert/to_image.hh>
-
#include <mln/debug/println.hh>
@@ -53,12 +52,11 @@
mln_assertion(rec.delta() == 2);
- for (int x = -5; x <= 5; ++x)
- for (int y = -5; y <= 5; ++y)
+ for (def::coord x = -5; x <= 5; ++x)
+ for (def::coord y = -5; y <= 5; ++y)
{
- mln_assertion((abs(x) <= 1 && abs(y) <= 2) == (rec.has(dpoint2d(x, y))));
+ mln_assertion((std::abs(x) <= 1 && std::abs(y) <= 2) == rec.has(dpoint2d(x, y)));
}
debug::println(convert::to_image(rec));
}
-
Index: tests/algebra/Makefile.am
--- tests/algebra/Makefile.am (revision 3113)
+++ tests/algebra/Makefile.am (working copy)
@@ -6,12 +6,14 @@
h_vec \
mat \
mat2 \
+ quat \
vec \
vec2
h_vec_SOURCES = h_vec.cc
mat_SOURCES = mat.cc
mat2_SOURCES = mat2.cc
+quat_SOURCES = quat.cc
vec_SOURCES = vec.cc
vec2_SOURCES = vec2.cc
Index: tests/algebra/quat.cc
--- tests/algebra/quat.cc (revision 3092)
+++ tests/algebra/quat.cc (working copy)
@@ -1,4 +1,5 @@
-// Copyright (C) 2007 EPITA Research and Development Laboratory
+// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory
+// (LRDE)
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -25,10 +26,9 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-/*! \file tests/value/quat.cc
- *
- * \brief Tests on mln::value::quat.
- */
+/// \file tests/algebra/quat.cc
+///
+/// Tests on mln::algebra::quat.
#include <iostream>
@@ -43,7 +43,7 @@
using namespace mln;
algebra::quat q1(3.f, 4.f, 1.6f, 0.5f);
- algebra::quat q2(1.2, make::vec(3, 6, 4));
+ algebra::quat q2(1.2f, make::vec(3, 6, 4));
algebra::quat q3(make::vec(1.3, 3., -6., 4.));
std::cout << q1 << std::endl;
@@ -52,7 +52,7 @@
std::cout << q1.s() << std::endl;
- q1.s() = 2.6;
+ q1.s() = 2.6f;
std::cout << q1 << std::endl;
std::cout << q1.v() << std::endl;
Property changes on: tests/algebra/quat.cc
___________________________________________________________________
Added: svn:mergeinfo
1
0
* mln/core/concept/function.hh: use a mutable_result type
instead of using a boolean. It avoids issues with the mutable type
which may differ from the result value of the function. Taking a
reference on the function result value *must* be different in order to
handle the case of a reference on an element in a vector of bool.
* mln/fun/i2v/array.hh,
* mln/fun/internal/array_base.hh,
* mln/fun/l2l/relabel.hh,
* mln/pw/image.hh: update in order to use the new mutable_result type.
---
milena/ChangeLog | 15 ++++++
milena/mln/core/concept/function.hh | 2 +-
milena/mln/fun/i2v/array.hh | 18 +++++---
milena/mln/fun/internal/array_base.hh | 76 ++++++++++++++++++++-------------
milena/mln/fun/l2l/relabel.hh | 21 +++++++--
milena/mln/pw/image.hh | 53 +++++++++++++----------
6 files changed, 120 insertions(+), 65 deletions(-)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index 57392db..2ea28d6 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,5 +1,20 @@
2008-12-30 Guillaume Lazzara <z(a)lrde.epita.fr>
+ Fix data mutability in pw::image.
+
+ * mln/core/concept/function.hh: use a mutable_result type
+ instead of using a boolean. It avoids issues with the mutable type
+ which may differ from the result value of the function. Taking a
+ reference on the function result value *must* be different in order to
+ handle the case of a reference on an element in a vector of bool.
+
+ * mln/fun/i2v/array.hh,
+ * mln/fun/internal/array_base.hh,
+ * mln/fun/l2l/relabel.hh,
+ * mln/pw/image.hh: update in order to use the new mutable_result type.
+
+2008-12-30 Guillaume Lazzara <z(a)lrde.epita.fr>
+
Add a call to center_at_() in
site_relative_iterator_base::center_at() (ticket #176).
diff --git a/milena/mln/core/concept/function.hh b/milena/mln/core/concept/function.hh
index 454a078..8aada68 100644
--- a/milena/mln/core/concept/function.hh
+++ b/milena/mln/core/concept/function.hh
@@ -100,7 +100,7 @@ namespace mln
struct Function_v2v : public Function<E>
{
typedef Function_v2v<void> category;
- typedef metal::false_ is_mutable; // Meaning: no mutable result by default.
+ typedef void mutable_result; // Meaning: no mutable result by default.
protected:
Function_v2v();
Function_v2v(const Function_v2v&);
diff --git a/milena/mln/fun/i2v/array.hh b/milena/mln/fun/i2v/array.hh
index 9bc48ef..f9ce0d1 100644
--- a/milena/mln/fun/i2v/array.hh
+++ b/milena/mln/fun/i2v/array.hh
@@ -38,7 +38,6 @@
# include <vector>
# include <algorithm>
# include <mln/fun/internal/array_base.hh>
-# include <mln/core/concept/function.hh>
# include <mln/util/array.hh>
@@ -89,10 +88,9 @@ namespace mln
{
template <typename T>
- class array : public Function_i2v< array<T> >,
- public internal::array_base<T>
+ class array : public internal::array_base< T, array<T> >
{
- typedef internal::array_base<T> super_base_;
+ typedef internal::array_base< T, array<T> > super_base_;
public:
@@ -112,10 +110,8 @@ namespace mln
/// Used in from_to(). Constructs that function from an std::vector.
/// Always prefer using from_to instead of this constructor.
array(const std::vector<T>& from);
-
/// \}
- typedef metal::true_ is_mutable;
};
} // end of namespace mln::fun::i2v
@@ -126,6 +122,16 @@ namespace mln
# ifndef MLN_INCLUDE_ONLY
+ // Init.
+
+ template <typename T1, typename T2>
+ void init_(tag::function_t,
+ fun::i2v::array<T1>& f,
+ const fun::i2v::array<T2>& model)
+ {
+ f.init_(model.size());
+ }
+
// convert::from_to
diff --git a/milena/mln/fun/internal/array_base.hh b/milena/mln/fun/internal/array_base.hh
index 3c7a154..3782ca4 100644
--- a/milena/mln/fun/internal/array_base.hh
+++ b/milena/mln/fun/internal/array_base.hh
@@ -36,6 +36,7 @@
# include <algorithm>
# include <mln/core/concept/function.hh>
# include <mln/util/array.hh>
+# include <mln/tag/init.hh>
namespace mln
@@ -47,24 +48,33 @@ namespace mln
namespace internal
{
- template <typename T>
- class array_base
+ template <typename T, typename E>
+ class array_base : public Function_i2v< E >
{
public:
+ /// Returned value types
+ /// \{
typedef T result;
- typedef metal::true_ is_mutable;
+ typedef typename std::vector<T>::reference mutable_result;
+ /// Set the function size to \p n.
void resize(unsigned n);
+ /// Set the function size to \p n and initialize the value with
+ /// \p val.
void resize(unsigned n, const T& val);
+ /// Return the number of values.
unsigned size() const;
- const T& operator()(unsigned i) const;
- T& operator()(unsigned i);
+ /// Const access to the ith value.
+ result operator()(unsigned i) const;
+ /// Read-Write access to the ith value.
+ mutable_result operator()(unsigned i);
+ /// Initialize an empty function.
+ void init_(unsigned n);
protected:
-
std::vector<T> v_;
/// Constructors
@@ -94,10 +104,8 @@ namespace mln
} // end of namespace mln::fun
-
# ifndef MLN_INCLUDE_ONLY
-
/// fun::internal::array_base
namespace fun
@@ -106,84 +114,92 @@ namespace mln
namespace internal
{
- template <typename T>
+ template <typename T, typename E>
inline
- array_base<T>::array_base()
+ array_base<T,E>::array_base()
{
}
- template <typename T>
+ template <typename T, typename E>
inline
- array_base<T>::array_base(unsigned n)
+ array_base<T,E>::array_base(unsigned n)
: v_(n)
{
}
- template <typename T>
+ template <typename T, typename E>
inline
- array_base<T>::array_base(unsigned n, const T& val)
+ array_base<T,E>::array_base(unsigned n, const T& val)
: v_(n, val)
{
}
- template <typename T>
+ template <typename T, typename E>
inline
- array_base<T>::array_base(const util::array<T>& from)
+ array_base<T,E>::array_base(const util::array<T>& from)
: v_(from.std_vector())
{
}
- template <typename T>
+ template <typename T, typename E>
inline
- array_base<T>::array_base(const std::vector<T>& from)
+ array_base<T,E>::array_base(const std::vector<T>& from)
: v_(from)
{
}
- template <typename T>
+ template <typename T, typename E>
inline
void
- array_base<T>::resize(unsigned n)
+ array_base<T,E>::resize(unsigned n)
{
v_.resize(n);
}
- template <typename T>
+ template <typename T, typename E>
inline
void
- array_base<T>::resize(unsigned n, const T& val)
+ array_base<T,E>::resize(unsigned n, const T& val)
{
v_.resize(n, val);
}
- template <typename T>
+ template <typename T, typename E>
inline
unsigned
- array_base<T>::size() const
+ array_base<T,E>::size() const
{
return v_.size();
}
- template <typename T>
+ template <typename T, typename E>
inline
- const T&
- array_base<T>::operator()(unsigned i) const
+ typename array_base<T,E>::result
+ array_base<T,E>::operator()(unsigned i) const
{
mln_precondition(i < v_.size());
return v_[i];
}
- template <typename T>
+ template <typename T, typename E>
inline
- T&
- array_base<T>::operator()(unsigned i)
+ typename array_base<T,E>::mutable_result
+ array_base<T,E>::operator()(unsigned i)
{
mln_precondition(i < v_.size());
return v_[i];
}
+ template <typename T, typename E>
+ inline
+ void
+ array_base<T,E>::init_(unsigned n)
+ {
+ v_.resize(n);
+ }
+
} // end of namespace mln::fun::internal
} // end of namespace mln::fun
diff --git a/milena/mln/fun/l2l/relabel.hh b/milena/mln/fun/l2l/relabel.hh
index b7bd7c4..0950e01 100644
--- a/milena/mln/fun/l2l/relabel.hh
+++ b/milena/mln/fun/l2l/relabel.hh
@@ -36,7 +36,6 @@
# include <vector>
# include <algorithm>
# include <mln/fun/internal/array_base.hh>
-# include <mln/core/concept/function.hh>
# include <mln/util/array.hh>
# include <mln/metal/converts_to.hh>
@@ -90,13 +89,15 @@ namespace mln
{
template <typename L>
- class relabel : public Function_l2l< relabel<L> >,
- public internal::array_base<L>
+ class relabel : public internal::array_base< L, relabel<L> >
{
- typedef internal::array_base<L> super_base_;
+ typedef internal::array_base< L, relabel<L> > super_base_;
public:
+ /// Constructors
+ /// \{
+
/// Default.
relabel();
/// Constructs a function with \p nvalues.
@@ -110,8 +111,8 @@ namespace mln
/// Used in from_to(). Constructs that function from an std::vector.
/// Always prefer using from_to instead of this constructor.
relabel(const std::vector<L>& from);
+ /// \}
- typedef metal::true_ is_mutable;
};
} // end of namespace mln::fun::l2l
@@ -122,6 +123,16 @@ namespace mln
# ifndef MLN_INCLUDE_ONLY
+ // Init.
+
+ template <typename T1, typename T2>
+ void init_(tag::function_t,
+ fun::l2l::relabel<T1>& f,
+ const fun::l2l::relabel<T2>& model)
+ {
+ f.init_(model.size());
+ }
+
// convert::from_to
diff --git a/milena/mln/pw/image.hh b/milena/mln/pw/image.hh
index 7208ab7..75696e6 100644
--- a/milena/mln/pw/image.hh
+++ b/milena/mln/pw/image.hh
@@ -38,12 +38,13 @@
# include <mln/core/concept/function.hh>
# include <mln/value/set.hh>
# include <mln/metal/unqualif.hh>
+# include <mln/metal/not_equal.hh>
namespace mln
{
- // Fwd decl.
+ // Forward declaration.
namespace pw { template <typename F, typename S> class image; }
@@ -78,9 +79,14 @@ namespace mln
// FIXME: the result type should *not* be qualified
template <typename F, typename S>
- struct image_< pw::image<F,S> > : default_image_< mlc_unqualif(mln_result(F)),
+ struct image_< pw::image<F,S> > : default_image_< mln_result(F),
pw::image<F,S> >
{
+ private:
+ typedef typename F::mutable_result mutable_result;
+ typedef mlc_not_equal(mutable_result, void) is_mutable;
+
+ public:
// misc
typedef trait::image::category::primary category;
typedef trait::image::speed::fast speed;
@@ -93,12 +99,12 @@ namespace mln
typedef trait::image::value_storage::disrupted value_storage;
typedef trait::image::value_browsing::site_wise_only value_browsing;
typedef trait::image::value_alignement::irrelevant value_alignement;
- typedef mlc_if(typename F::is_mutable,
+ typedef mlc_if(is_mutable,
trait::image::value_io::read_write,
trait::image::value_io::read_only) value_io;
// site / domain
- typedef mlc_if(typename F::is_mutable,
+ typedef mlc_if(is_mutable,
trait::image::pw_io::read_write,
trait::image::pw_io::read) pw_io;
typedef /* FIXME: depends on S */ undef localization;
@@ -122,11 +128,16 @@ namespace mln
class image :
public internal::image_primary<mln_result(F), S, image<F,S> >
{
+ typedef typename F::mutable_result mutable_result;
+ typedef mlc_not_equal(mutable_result, void) is_mutable;
+
public:
/// Skeleton.
typedef image< tag::function_<F>, tag::pset_<S> > skeleton;
+ /// Function associated type.
+ typedef F function_t;
/// Value associated type.
typedef mln_result(F) value;
@@ -135,7 +146,7 @@ namespace mln
typedef mln_result(F) rvalue;
/// Return type of read-write access.
- typedef mlc_if(typename F::is_mutable, mln_result(F)&, mln_result(F)) lvalue;
+ typedef mlc_if(is_mutable, mutable_result, mln_result(F)) lvalue;
/// Constructor without argument.
image();
@@ -153,44 +164,40 @@ namespace mln
F function() const;
/// Read-only access of pixel value at point site \p p.
- mln_result(F) operator()(const mln_psite(S)& p) const;
+ rvalue operator()(const mln_psite(S)& p) const;
/// Read-write access returns either a temporary value (copy) or
/// a reference in the case of a mutable function (container).
- lvalue operator()(const mln_psite(S)&);
+ lvalue operator()(const mln_psite(S)& p);
};
} // end of namespace mln::pw
- template <typename F, typename S>
- void init_(tag::function_t, Function_v2v<F>& target,
- const mln::pw::image<F,S>& model);
-
- template <typename F, typename S, typename J>
- void init_(tag::image_t, mln::pw::image<F,S>& target, const J& model);
-
-
-
# ifndef MLN_INCLUDE_ONLY
// init_
template <typename F, typename S>
- void init_(tag::function_t, Function_v2v<F>& target,
- const mln::pw::image<F,S>& model)
+ void init_(tag::function_t, F& f, const pw::image<F,S>& model)
+ {
+ f = model.function();
+ }
+
+ template <typename F1, typename F2, typename S>
+ void init_(tag::function_t, F1& f, const pw::image<F2,S>& model)
{
- target = model.function();
+ init_(tag::function, f, model.function());
}
template <typename F, typename S, typename J>
- void init_(tag::image_t, mln::pw::image<F,S>& target, const J& model)
+ void init_(tag::image_t, pw::image<F,S>& target, const J& model)
{
F f;
- init_(tag::function, f, model);
+ init_(tag::function, f, exact(model));
S s;
- init_(tag::domain, s, model);
+ init_(tag::domain, s, exact(model));
target.init_(f, s);
}
@@ -265,7 +272,7 @@ namespace mln
template <typename F, typename S>
inline
- mln_result(F)
+ typename image<F,S>::rvalue
image<F,S>::operator()(const mln_psite(S)& p) const
{
mln_precondition(this->data_->pset_.has(p));
--
1.5.6.5
1
0
3112: Add a call to center_at_() in site_relative_iterator_base::center_at() (ticket #176).
by Guillaume Lazzara 30 Dec '08
by Guillaume Lazzara 30 Dec '08
30 Dec '08
* mln/core/dpsites_piter.hh,
* mln/core/image/complex_neighborhood_piter.hh,
* mln/core/image/graph_window_piter.hh,
* mln/core/neighb.hh: implement center_at_().
* mln/core/internal/site_relative_iterator_base.hh: call center_at_().
Derived classes must implement that method.
---
milena/ChangeLog | 13 ++++
milena/mln/core/dpsites_piter.hh | 74 ++++++++++++-------
.../mln/core/image/complex_neighborhood_piter.hh | 33 +++------
milena/mln/core/image/graph_window_piter.hh | 29 +++++---
.../core/internal/site_relative_iterator_base.hh | 3 +-
milena/mln/core/neighb.hh | 24 ++++++
6 files changed, 116 insertions(+), 60 deletions(-)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index 6e38723..57392db 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,5 +1,18 @@
2008-12-30 Guillaume Lazzara <z(a)lrde.epita.fr>
+ Add a call to center_at_() in
+ site_relative_iterator_base::center_at() (ticket #176).
+
+ * mln/core/dpsites_piter.hh,
+ * mln/core/image/complex_neighborhood_piter.hh,
+ * mln/core/image/graph_window_piter.hh,
+ * mln/core/neighb.hh: implement center_at_().
+
+ * mln/core/internal/site_relative_iterator_base.hh: call center_at_().
+ Derived classes must implement that method.
+
+2008-12-30 Guillaume Lazzara <z(a)lrde.epita.fr>
+
Fix from_to dispatch.
* mln/convert/from_to.hh: dispatch functions where not called at all.
diff --git a/milena/mln/core/dpsites_piter.hh b/milena/mln/core/dpsites_piter.hh
index 99d95f5..6895cba 100644
--- a/milena/mln/core/dpsites_piter.hh
+++ b/milena/mln/core/dpsites_piter.hh
@@ -1,4 +1,5 @@
// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory
+// (LRDE)
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -28,11 +29,10 @@
#ifndef MLN_CORE_DPSITES_PITER_HH
# define MLN_CORE_DPSITES_PITER_HH
-/*! \file mln/core/dpsites_piter.hh
- *
- * \brief Definition of forward and backward mln::dpoint_ based
- * iterators.
- */
+/// \file mln/core/dpsites_piter.hh
+///
+/// Definition of forward and backward mln::dpoint_ based
+/// iterators.
# include <vector>
# include <mln/core/internal/site_relative_iterator_base.hh>
@@ -41,23 +41,21 @@
namespace mln
{
- /*! \brief A generic forward iterator on points of windows and of
- * neighborhoods.
- *
- * The parameter \c V is the type of std::vector enclosing
- * structure.
- */
+ /// A generic forward iterator on points of windows and of
+ /// neighborhoods.
+ ///
+ /// The parameter \c V is the type of std::vector enclosing
+ /// structure.
template <typename V>
class dpsites_fwd_piter
: public internal::site_relative_iterator_base< V, dpsites_fwd_piter<V> >
{
public:
- /*! \brief Constructor.
- *
- * \param[in] v Object that can provide an array of delta-points.
- * \param[in] c Center point to iterate around.
- */
+ /// Constructor.
+ ///
+ /// \param[in] v Object that can provide an array of delta-points.
+ /// \param[in] c Center point to iterate around.
template <typename P>
dpsites_fwd_piter(const V& v, const P& c);
@@ -76,6 +74,10 @@ namespace mln
/// Go to the next point.
void do_next_();
+ /// Set the reference psite.
+ template <typename Pref>
+ void center_at_(const Pref&);
+
/// Compute the current psite.
mln_psite(V) compute_p_() const;
@@ -85,23 +87,21 @@ namespace mln
};
- /*! \brief A generic backward iterator on points of windows and of
- * neighborhoods.
- *
- * The parameter \c V is the type of std::vector enclosing
- * structure.
- */
+ /// A generic backward iterator on points of windows and of
+ /// neighborhoods.
+ ///
+ /// The parameter \c V is the type of std::vector enclosing
+ /// structure.
template <typename V>
class dpsites_bkd_piter :
public internal::site_relative_iterator_base< V, dpsites_bkd_piter<V> >
{
public:
- /*! \brief Constructor.
- *
- * \param[in] v Object that can provide an array of delta-points.
- * \param[in] c Center point to iterate around.
- */
+ /// Constructor.
+ ///
+ /// \param[in] v Object that can provide an array of delta-points.
+ /// \param[in] c Center point to iterate around.
template <typename P>
dpsites_bkd_piter(const V& v, const P& c);
@@ -120,6 +120,10 @@ namespace mln
/// Go to the next point.
void do_next_();
+ /// Set the reference psite.
+ template <typename Pref>
+ void center_at_(const Pref&);
+
/// Compute the current psite.
mln_psite(V) compute_p_() const;
@@ -183,6 +187,14 @@ namespace mln
}
template <typename V>
+ template <typename Pref>
+ inline
+ void
+ dpsites_fwd_piter<V>::center_at_(const Pref&)
+ {
+ }
+
+ template <typename V>
inline
mln_psite(V)
dpsites_fwd_piter<V>::compute_p_() const
@@ -241,6 +253,14 @@ namespace mln
}
template <typename V>
+ template <typename Pref>
+ inline
+ void
+ dpsites_bkd_piter<V>::center_at_(const Pref&)
+ {
+ }
+
+ template <typename V>
inline
mln_psite(V)
dpsites_bkd_piter<V>::compute_p_() const
diff --git a/milena/mln/core/image/complex_neighborhood_piter.hh b/milena/mln/core/image/complex_neighborhood_piter.hh
index 6c44649..f69455c 100644
--- a/milena/mln/core/image/complex_neighborhood_piter.hh
+++ b/milena/mln/core/image/complex_neighborhood_piter.hh
@@ -41,9 +41,7 @@
internal::site_relative_iterator_base? I might duplicate things,
since most of the implementation of this iterator is delegated to
the underlying complex iter. Moreover, change_target_() is
- useless, and center_at() ``hides'' an existing method in (one of)
- the super class(es) which is not sound, IMHO. Think about
- introducing base class replacement. */
+ useless. Think about introducing base class replacement. */
namespace mln
@@ -53,7 +51,7 @@ namespace mln
| complex_neighborhood_fwd_piter<I, G, N>. |
`------------------------------------------*/
- /// \brief Forward iterator on complex neighborhood.
+ /// Forward iterator on complex neighborhood.
template <typename I, typename G, typename N>
class complex_neighborhood_fwd_piter
: public internal::site_relative_iterator_base< N,
@@ -90,16 +88,13 @@ namespace mln
void do_next_();
/// Set the reference psite.
- /* FIXME: Careful, this method overrides the (non virtual) method
- internal::site_relative_iterator_base<S, E>::center_at. See
- FIXME above. */
template <typename Pref>
- void center_at(const Pref& c);
+ void center_at_(const Pref& c);
/// Compute the current psite.
psite compute_p_() const;
/// \}
- /// \brief Accessors.
+ /// Accessors.
/// \{
const iter_type& iter() const;
iter_type& iter();
@@ -122,7 +117,7 @@ namespace mln
| complex_neighborhood_bkd_piter<I, G, N>. |
`------------------------------------------*/
- /// \brief Backward iterator on complex neighborhood.
+ /// Backward iterator on complex neighborhood.
template <typename I, typename G, typename N>
class complex_neighborhood_bkd_piter
: public internal::site_relative_iterator_base< N,
@@ -159,16 +154,14 @@ namespace mln
void do_next_();
/// Set the reference psite.
- /* FIXME: Careful, this method overrides the (non virtual) method
- internal::site_relative_iterator_base<S, E>::center_at. See
- FIXME above. */
template <typename Pref>
- void center_at(const Pref& c);
+ void center_at_(const Pref&);
+
/// Compute the current psite.
psite compute_p_() const;
/// \}
- /// \brief Accessors.
+ /// Accessors.
/// \{
const iter_type& iter() const;
iter_type& iter();
@@ -207,7 +200,7 @@ namespace mln
const Pref& p_ref)
{
this->change_target(exact(nbh));
- center_at(p_ref);
+ this->center_at(p_ref);
mln_postcondition(!this->is_valid());
}
@@ -247,9 +240,8 @@ namespace mln
template <typename Pref>
inline
void
- complex_neighborhood_fwd_piter<I, G, N>::center_at(const Pref& c)
+ complex_neighborhood_fwd_piter<I, G, N>::center_at_(const Pref& c)
{
- super_::center_at(c);
iter_.center_at(this->center().face());
}
@@ -305,7 +297,7 @@ namespace mln
const Pref& p_ref)
{
this->change_target(exact(nbh));
- center_at(p_ref);
+ this->center_at(p_ref);
mln_postcondition(!this->is_valid());
}
@@ -345,9 +337,8 @@ namespace mln
template <typename Pref>
inline
void
- complex_neighborhood_bkd_piter<I, G, N>::center_at(const Pref& c)
+ complex_neighborhood_bkd_piter<I, G, N>::center_at_(const Pref& c)
{
- super_::center_at(c);
iter_.center_at(this->center().face());
}
diff --git a/milena/mln/core/image/graph_window_piter.hh b/milena/mln/core/image/graph_window_piter.hh
index 86abb4d..a6b29e3 100644
--- a/milena/mln/core/image/graph_window_piter.hh
+++ b/milena/mln/core/image/graph_window_piter.hh
@@ -39,6 +39,8 @@
namespace mln
{
+ // Forward declaration.
+ template <typename S, typename I> class p_graph_piter;
/// Forward iterator on line graph window.
template <typename S, typename W, typename I>
@@ -53,10 +55,6 @@ namespace mln
/// Associated types
/// \{
typedef mln_result(S::fun_t) P;
- enum { dim = P::dim };
-
- // FIXME: Dummy typedef.
- typedef void dpoint;
/// \}
/// Construction.
@@ -80,11 +78,12 @@ namespace mln
void do_next_();
/// Set the reference psite.
- /* FIXME: Careful, this method overrides the (non virtual) method
- internal::site_relative_iterator_base<S, E>::center_at. See
- FIXME above. */
template <typename Pref>
- void center_at(const Pref& c);
+ void center_at_(const Pref& c);
+
+ /// Set the reference psite.
+ template <typename I2>
+ void center_at_(const p_graph_piter<S, I2>& c);
/// Return the graph element pointed by this iterator.
const mln_graph_element(S)& element() const;
@@ -119,7 +118,7 @@ namespace mln
graph_window_piter<S,W,I>::graph_window_piter(const Window<W>& win,
const Pref& p_ref)
{
- center_at(p_ref);
+ this->center_at(p_ref);
this->change_target(exact(win));
mln_postcondition(!this->is_valid());
}
@@ -160,9 +159,17 @@ namespace mln
template <typename Pref>
inline
void
- graph_window_piter<S, W, I>::center_at(const Pref& c)
+ graph_window_piter<S, W, I>::center_at_(const Pref& c)
+ {
+ iter_.center_at(c.p_hook_());
+ }
+
+ template <typename S, typename W, typename I>
+ template <typename I2>
+ inline
+ void
+ graph_window_piter<S, W, I>::center_at_(const p_graph_piter<S, I2>& c)
{
- super_::center_at(c);
iter_.center_at(c.hook_elt_());
}
diff --git a/milena/mln/core/internal/site_relative_iterator_base.hh b/milena/mln/core/internal/site_relative_iterator_base.hh
index 4438134..c65503f 100644
--- a/milena/mln/core/internal/site_relative_iterator_base.hh
+++ b/milena/mln/core/internal/site_relative_iterator_base.hh
@@ -56,7 +56,7 @@ namespace mln
/// Parameter \c S is the targeted "site set definition" type. It
/// can be either a Window, or a Neighborhood.
///
- /// IMPORTANT: Sub-classes have to define do_start_, do_next_,
+ /// IMPORTANT: Sub-classes have to define center_at_, do_start_, do_next_,
/// is_valid_, invalidate_ and compute_p_. They shall define
/// NEITHER start_ NOR next_.
///
@@ -142,6 +142,7 @@ namespace mln
mlc_converts_to(P, const mln_psite(S)&)::check();
c_ = & static_cast< const mln_psite(S)& >(c);
this->invalidate();
+ exact(this)->center_at_(c);
}
template <typename S, typename E>
diff --git a/milena/mln/core/neighb.hh b/milena/mln/core/neighb.hh
index f1ebf69..d509af0 100644
--- a/milena/mln/core/neighb.hh
+++ b/milena/mln/core/neighb.hh
@@ -140,6 +140,10 @@ namespace mln
/// Go to the next point.
void do_next_();
+ /// Do some work while centering the iterator.
+ template <typename Pref>
+ void center_at_(const Pref&);
+
/// Compute the current psite.
mln_psite(W) compute_p_() const;
@@ -178,6 +182,10 @@ public:
/// Go to the next point.
void do_next_();
+ /// Do some work while centering the iterator.
+ template <typename Pref>
+ void center_at_(const Pref&);
+
/// Compute the current psite.
mln_psite(W) compute_p_() const;
@@ -310,6 +318,14 @@ protected:
}
template <typename W>
+ template <typename Pref>
+ inline
+ void
+ neighb_fwd_niter<W>::center_at_(const Pref&)
+ {
+ }
+
+ template <typename W>
inline
mln_psite(W)
neighb_fwd_niter<W>::compute_p_() const
@@ -370,6 +386,14 @@ protected:
}
template <typename W>
+ template <typename Pref>
+ inline
+ void
+ neighb_bkd_niter<W>::center_at_(const Pref&)
+ {
+ }
+
+ template <typename W>
inline
mln_psite(W)
neighb_bkd_niter<W>::compute_p_() const
--
1.5.6.5
1
0