* milena/mln/accu/line.hh: avoid compilation warnings.
* milena/mln/accu/volume.hh: Fix missing include.
* milena/mln/core/dpsites_piter.hh: use to_vec() instead of
std_vector().
* milena/mln/core/image/tr_image.hh: call to_vec();
* milena/mln/debug/println_with_border.spe.hh: use point_at_index()
instead of operator[].
* milena/mln/trait/value_.hh: change max card value for low
quantification.
* milena/mln/util/internal/graph_psite_base.hh: Add missing operators.
* milena/tests/core/image/tr_image.cc: fix include.
* milena/tests/core/other/box_runstart_piter.cc: remove make::
prefix.
* milena/tests/core/other/point_set_compatibility.cc: update test
according last changes in p_vertices.
---
milena/ChangeLog | 29 ++++++
milena/mln/accu/line.hh | 4 +-
milena/mln/accu/volume.hh | 1 +
milena/mln/core/dpsites_piter.hh | 10 +-
milena/mln/core/image/tr_image.hh | 4 +-
milena/mln/debug/println_with_border.spe.hh | 2 +-
milena/mln/trait/value_.hh | 2 +-
milena/mln/util/internal/graph_psite_base.hh | 96 ++++++++++++++++++--
milena/tests/core/image/tr_image.cc | 8 +-
milena/tests/core/other/box_runstart_piter.cc | 8 +-
milena/tests/core/other/point_set_compatibility.cc | 36 ++++----
11 files changed, 153 insertions(+), 47 deletions(-)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index afed71f..f69b232 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,3 +1,32 @@
+2008-11-04 Guillaume Lazzara <z(a)lrde.epita.fr>
+
+ Various small fixes.
+
+ * milena/mln/accu/line.hh: avoid compilation warnings.
+
+ * milena/mln/accu/volume.hh: Fix missing include.
+
+ * milena/mln/core/dpsites_piter.hh: use to_vec() instead of
+ std_vector().
+
+ * milena/mln/core/image/tr_image.hh: call to_vec();
+
+ * milena/mln/debug/println_with_border.spe.hh: use point_at_index()
+ instead of operator[].
+
+ * milena/mln/trait/value_.hh: change max card value for low
+ quantification.
+
+ * milena/mln/util/internal/graph_psite_base.hh: Add missing operators.
+
+ * milena/tests/core/image/tr_image.cc: fix include.
+
+ * milena/tests/core/other/box_runstart_piter.cc: remove make::
+ prefix.
+
+ * milena/tests/core/other/point_set_compatibility.cc: update test
+ according last changes in p_vertices.
+
2008-11-04 Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
Update level stretch so that output is returned.
diff --git a/milena/mln/accu/line.hh b/milena/mln/accu/line.hh
index 8766085..cb484d7 100644
--- a/milena/mln/accu/line.hh
+++ b/milena/mln/accu/line.hh
@@ -78,8 +78,8 @@ namespace mln
typename I, typename O>
void
line_tests(const Image<I>& input_,
- const mln_site(I)& p_start, unsigned len,
- unsigned half_length,
+ const mln_site(I)&, unsigned,
+ unsigned,
Image<O>& output_)
{
mlc_is_a(Meta_Accu, Meta_Accumulator)::check();
diff --git a/milena/mln/accu/volume.hh b/milena/mln/accu/volume.hh
index 8be5ac8..705434b 100644
--- a/milena/mln/accu/volume.hh
+++ b/milena/mln/accu/volume.hh
@@ -42,6 +42,7 @@
# include <mln/accu/internal/base.hh>
# include <mln/core/concept/meta_accumulator.hh>
+# include <mln/math/abs.hh>
# include <mln/util/pix.hh>
# include <mln/literal/zero.hh>
diff --git a/milena/mln/core/dpsites_piter.hh b/milena/mln/core/dpsites_piter.hh
index 99d95f5..07a9cc2 100644
--- a/milena/mln/core/dpsites_piter.hh
+++ b/milena/mln/core/dpsites_piter.hh
@@ -155,7 +155,7 @@ namespace mln
bool
dpsites_fwd_piter<V>::is_valid_() const
{
- return i_ != this->s_->std_vector().size();
+ return i_ != this->s_->to_vec().size();
}
template <typename V>
@@ -163,7 +163,7 @@ namespace mln
void
dpsites_fwd_piter<V>::invalidate_()
{
- i_ = this->s_->std_vector().size();
+ i_ = this->s_->to_vec().size();
}
template <typename V>
@@ -187,7 +187,7 @@ namespace mln
mln_psite(V)
dpsites_fwd_piter<V>::compute_p_() const
{
- return *this->c_ + this->s_->std_vector()[i_];
+ return *this->c_ + this->s_->to_vec()[i_];
}
@@ -229,7 +229,7 @@ namespace mln
void
dpsites_bkd_piter<V>::do_start_()
{
- i_ = this->s_->std_vector().size() - 1;
+ i_ = this->s_->to_vec().size() - 1;
}
template <typename V>
@@ -245,7 +245,7 @@ namespace mln
mln_psite(V)
dpsites_bkd_piter<V>::compute_p_() const
{
- return *this->c_ + this->s_->std_vector()[i_];
+ return *this->c_ + this->s_->to_vec()[i_];
}
# endif // ! MLN_INCLUDE_ONLY
diff --git a/milena/mln/core/image/tr_image.hh b/milena/mln/core/image/tr_image.hh
index 1b5d055..6459750 100644
--- a/milena/mln/core/image/tr_image.hh
+++ b/milena/mln/core/image/tr_image.hh
@@ -202,7 +202,7 @@ namespace mln
mln_value(I)
tr_image<S,I,T>::operator()(const psite& p) const
{
- algebra::vec<I::psite::dim, float> v = p;
+ algebra::vec<I::psite::dim, float> v = p.to_vec();
return this->data_->ima_(this->data_->tr_.inv()(v));
}
@@ -211,7 +211,7 @@ namespace mln
mln_value(I)
tr_image<S,I,T>::operator()(const psite& p)
{
- algebra::vec<I::psite::dim, float> v = p;
+ algebra::vec<I::psite::dim, float> v = p.to_vec();
return this->data_->ima_(this->data_->tr_.inv()(v));
}
diff --git a/milena/mln/debug/println_with_border.spe.hh
b/milena/mln/debug/println_with_border.spe.hh
index c57f7c1..b03e675 100644
--- a/milena/mln/debug/println_with_border.spe.hh
+++ b/milena/mln/debug/println_with_border.spe.hh
@@ -95,7 +95,7 @@ namespace mln
for (unsigned j = 0; j < real_len_r; ++j)
{
for (unsigned i = 0; i < real_len_c; ++i)
- std::cout << format(input[k * (real_len_r * real_len_c) + j * real_len_c + i])
+ std::cout << format(input.point_at_index(k * (real_len_r * real_len_c) + j *
real_len_c + i))
<< ' ';
std::cout << std::endl;
}
diff --git a/milena/mln/trait/value_.hh b/milena/mln/trait/value_.hh
index 749654f..8e2e6b3 100644
--- a/milena/mln/trait/value_.hh
+++ b/milena/mln/trait/value_.hh
@@ -73,7 +73,7 @@
mln::trait::value::quant::low)
# define mln_value_card_from_(N) \
- (N <= 16 \
+ (N <= 12 \
? mlc_pow_int((N <= 16 ? 2 : 1), \
(N <= 16 ? N : 1)) \
: 0)
diff --git a/milena/mln/util/internal/graph_psite_base.hh
b/milena/mln/util/internal/graph_psite_base.hh
index 8e5a515..c0d5a0c 100644
--- a/milena/mln/util/internal/graph_psite_base.hh
+++ b/milena/mln/util/internal/graph_psite_base.hh
@@ -69,6 +69,8 @@ namespace mln
void update_id(unsigned v_id);
/// \}
+ /// Getters.
+ /// \{
/// Return the target (the site set).
const target* target_() const; // Hook to the target.
@@ -78,6 +80,11 @@ namespace mln
/// Return the graph associated to the target of this psite.
const graph_t& graph() const;
+ /// Return the graph associated to the target of this psite.
+ unsigned id() const;
+
+ /// \}
+
/// Check whether it is valid.
bool is_valid() const;
/// Invalidate this psite.
@@ -110,11 +117,43 @@ namespace mln
V v_;
};
- } // end of namespace internal
-
template <typename V, typename P, typename S, typename E>
std::ostream&
- operator<<(std::ostream& ostr, internal::graph_psite_base<V, P, S,
E>& p);
+ operator<<(std::ostream& ostr, graph_psite_base<V, P, S, E>& p);
+
+ /// Comparison of two mln::graph_psite_base<V, P, S, E> instances.
+ /// \{
+ /* FIXME: Shouldn't those comparisons be part of a much general
+ mechanism? */
+
+ /// \brief Is \a lhs equal to \a rhs?
+ ///
+ /// \pre Arguments \a lhs and \a rhs must belong to the same
+ /// mln::p_vertices.
+ template <typename V, typename P, typename S, typename E>
+ bool
+ operator==(const graph_psite_base<V, P, S, E>& lhs, const
graph_psite_base<V, P, S, E>& rhs);
+
+ /// \brief Is \a lhs not equal to \a rhs?
+ ///
+ /// \pre Arguments \a lhs and \a rhs must belong to the same
+ /// mln::p_vertices.
+ template <typename V, typename P, typename S, typename E>
+ bool
+ operator!=(const graph_psite_base<V, P, S, E>& lhs, const
graph_psite_base<V, P, S, E>& rhs);
+
+ /// \brief Is \a lhs ``less'' than \a rhs?
+ ///
+ /// This comparison is required by algorithms sorting psites.
+ ///
+ /// \pre Arguments \a lhs and \a rhs must belong to the same
+ /// mln::p_vertices.
+ template <typename V, typename P, typename S, typename E>
+ bool
+ operator< (const graph_psite_base<V, P, S, E>& lhs, const
graph_psite_base<V, P, S, E>& rhs);
+ /// \}
+
+ } // end of namespace internal
} // end of namespace mln
@@ -192,6 +231,14 @@ namespace mln
return t_->graph();
}
+ template <typename v, typename p, typename s, typename e>
+ inline
+ unsigned
+ graph_psite_base<v, p, s, e>::id() const
+ {
+ return v_.id();
+ }
+
template <typename V, typename P, typename S, typename E>
inline
bool
@@ -225,14 +272,43 @@ namespace mln
return t_->function()(v_.id());
}
- } // end of namespace internal
- template <typename V, typename P, typename S, typename E>
- std::ostream&
- operator<<(std::ostream& ostr, internal::graph_psite_base<V, P, S,
E>& p)
- {
- return ostr << p.subj_();
- }
+ template <typename V, typename P, typename S, typename E>
+ std::ostream&
+ operator<<(std::ostream& ostr, graph_psite_base<V, P, S, E>&
p)
+ {
+ return ostr << p.unproxy_();
+ }
+
+ /*--------------.
+ | Comparisons. |
+ `--------------*/
+
+ template <typename V, typename P, typename S, typename E>
+ bool
+ operator==(const graph_psite_base<V, P, S, E>& lhs, const
graph_psite_base<V, P, S, E>& rhs)
+ {
+ mln_assertion(lhs.target_() == rhs.target_());
+ return lhs.id() == rhs.id();
+ }
+
+ template <typename V, typename P, typename S, typename E>
+ bool
+ operator!=(const graph_psite_base<V, P, S, E>& lhs, const
graph_psite_base<V, P, S, E>& rhs)
+ {
+ mln_assertion(lhs.target_() == rhs.target_());
+ return lhs.id() != rhs.id();
+ }
+
+ template <typename V, typename P, typename S, typename E>
+ bool
+ operator< (const graph_psite_base<V, P, S, E>& lhs, const
graph_psite_base<V, P, S, E>& rhs)
+ {
+ mln_assertion(lhs.target_() == rhs.target_());
+ return lhs.id() < rhs.id();
+ }
+
+ } // end of namespace internal
} // end of namespace mln
diff --git a/milena/tests/core/image/tr_image.cc b/milena/tests/core/image/tr_image.cc
index 83b62b5..90b2b9f 100644
--- a/milena/tests/core/image/tr_image.cc
+++ b/milena/tests/core/image/tr_image.cc
@@ -32,7 +32,7 @@
#include <iostream>
-#include <mln/fun/x2x/geom/rotation.hh>
+#include <mln/fun/x2x/rotation.hh>
#include <mln/core/image/image3d.hh>
#include <mln/value/int_u8.hh>
#include <mln/core/image/tr_image.hh>
@@ -50,18 +50,18 @@ int main()
debug::iota(in);
debug::println(in);
- fun::x2x::geom::rotation<3,float> rot1(1.67, literal::zero);
+ fun::x2x::rotation<3, float> rot1(1.67, literal::zero);
tr_image<mln_pset_(image3d<int_u8>),
image3d<int_u8>,
- fun::x2x::geom::rotation<3,float> >
+ fun::x2x::rotation<3, float> >
inter(out.domain(), in, rot1);
image3d<int_u8>::fwd_piter p(out.domain());
for_all(p)
{
- algebra::vec<3,int> vec = p.to_site().to_vec();
+ algebra::vec<3, int> vec = p.to_site().to_vec();
if (inter.has(p))
out(p) = inter(vec);
else
diff --git a/milena/tests/core/other/box_runstart_piter.cc
b/milena/tests/core/other/box_runstart_piter.cc
index 7730ac3..7aaab59 100644
--- a/milena/tests/core/other/box_runstart_piter.cc
+++ b/milena/tests/core/other/box_runstart_piter.cc
@@ -38,11 +38,9 @@ int main()
{
using namespace mln;
- const unsigned border = 2;
-
/// Test with box1d
{
- box1d b1(make::point1d(40), make::point1d(42));
+ box1d b1(point1d(40), point1d(42));
box_runstart_piter<point1d> p1(b1);
for_all(p1)
{
@@ -56,7 +54,7 @@ int main()
/// Test with box2d
{
- box2d b2(make::point2d(1,2), make::point2d(5,8));
+ box2d b2(point2d(1,2), point2d(5,8));
box_runstart_piter<point2d> p2(b2);
int i = 1;
for_all(p2)
@@ -70,7 +68,7 @@ int main()
// Test with image 3d
{
- box3d b3(make::point3d(1,2,3), make::point3d(5,8,7));
+ box3d b3(point3d(1,2,3), point3d(5,8,7));
box_runstart_piter<point3d> p3(b3);
int i = 1;
int j = 2;
diff --git a/milena/tests/core/other/point_set_compatibility.cc
b/milena/tests/core/other/point_set_compatibility.cc
index e309187..0efec07 100644
--- a/milena/tests/core/other/point_set_compatibility.cc
+++ b/milena/tests/core/other/point_set_compatibility.cc
@@ -33,8 +33,8 @@
#include <mln/core/site_set/p_array.hh>
#include <mln/core/site_set/p_set.hh>
-#include <mln/core/image/graph_psite.hh>
-#include <mln/core/site_set/p_graph_piter.hh>
+#include <mln/core/site_set/p_vertices.hh>
+#include <mln/util/graph.hh>
int main()
@@ -46,21 +46,22 @@ int main()
| mln::p_array_piter. |
`--------------------------------------------------------*/
- // Graph.
+ // Graph
- // 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.
+ //Vertices
+ typedef fun::i2v::array<point2d> fpoint_t;
+ fpoint_t 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.
- util::graph<point2d> g;
+ util::graph g;
// Populate the graph with vertices.
for (unsigned i = 0; i < points.size(); ++i)
- g.add_vertex (points[i]);
+ g.add_vertex();
// Populate the graph with edges.
g.add_edge(0, 1);
g.add_edge(1, 2);
@@ -69,10 +70,11 @@ int main()
g.add_edge(4, 2);
+
// Graph point set.
- typedef p_graph<point2d> pg_t;
- p_graph<point2d> pg(g);
- typedef graph_psite<point2d> gpsite_t;
+ typedef p_vertices<util::graph, fpoint_t> pv_t;
+ typedef mln_psite_(pv_t) gpsite_t;
+ pv_t pv(g, points);
{
// Array of graph point sites.
@@ -80,7 +82,7 @@ int main()
pa_t pa;
// Tests: copying all psites from PG to PA.
- mln_piter_(pg_t) p(pg);
+ mln_piter_(pv_t) p(pv);
for_all (p)
pa.append(p);
@@ -97,7 +99,7 @@ int main()
ps_t ps;
// Tests: copying all psites from PG to PS.
- mln_piter_(pg_t) p(pg);
+ mln_piter_(pv_t) p(pv);
for_all (p)
ps.insert(p);
--
1.5.6.5