last-svn-commit-162-gf89278c Fix a bug in conversions from vec to point.

* milena/mln/core/concept/gpoint.hh: Fix comment. * milena/mln/core/image/image1d.hh: Share a dpoint value. * milena/mln/core/point.hh: Handle point1d. --- milena/ChangeLog | 10 ++++++++++ milena/mln/core/concept/gpoint.hh | 2 +- milena/mln/core/image/image1d.hh | 6 ++++-- milena/mln/core/point.hh | 28 ++++++++++++++++++++-------- 4 files changed, 35 insertions(+), 11 deletions(-) diff --git a/milena/ChangeLog b/milena/ChangeLog index 15a34bc..a3b5d0a 100644 --- a/milena/ChangeLog +++ b/milena/ChangeLog @@ -1,3 +1,13 @@ +2010-06-18 Guillaume Lazzara <z@lrde.epita.fr> + + Fix a bug in conversions from vec to point. + + * milena/mln/core/concept/gpoint.hh: Fix comment. + + * milena/mln/core/image/image1d.hh: Share a dpoint value. + + * milena/mln/core/point.hh: Handle point1d. + 2010-06-15 Guillaume Lazzara <z@lrde.epita.fr> Introduce labeling::value_and_compute. diff --git a/milena/mln/core/concept/gpoint.hh b/milena/mln/core/concept/gpoint.hh index f0e094b..f9bba11 100644 --- a/milena/mln/core/concept/gpoint.hh +++ b/milena/mln/core/concept/gpoint.hh @@ -182,7 +182,7 @@ namespace mln * topology and with the same type of coordinates; otherwise this * test does not compile. * - * \post The result, \p dp, is such as \p lhs == \p rhs + \p dp. + * \post The result, \p dp, is such as \p lhs == \p rhs + \p dp. * * \return A delta point (temporary object). * diff --git a/milena/mln/core/image/image1d.hh b/milena/mln/core/image/image1d.hh index e416a9e..89e93e7 100644 --- a/milena/mln/core/image/image1d.hh +++ b/milena/mln/core/image/image1d.hh @@ -304,8 +304,10 @@ namespace mln void data< image1d<T> >::update_vb_() { - vb_.pmin() = b_.pmin() - dpoint1d(all_to(bdr_)); - vb_.pmax() = b_.pmax() + dpoint1d(all_to(bdr_)); + dpoint1d dp(all_to(bdr_)); + + vb_.pmin() = b_.pmin() - dp; + vb_.pmax() = b_.pmax() + dp; } template <typename T> diff --git a/milena/mln/core/point.hh b/milena/mln/core/point.hh index 8da15b6..50a0f6b 100644 --- a/milena/mln/core/point.hh +++ b/milena/mln/core/point.hh @@ -353,10 +353,16 @@ namespace mln point<G,C>::point(const algebra::vec<dim,double>& v) { unsigned j = 0; - for (unsigned i = dim - 2; i < dim; ++i) - coord_[i] = round(v[j++]); - for (unsigned i = 2; i < dim; ++i, ++j) - coord_[i-j] = round(v[j]); + //FIXME: to be improved while adding a conversion routine. + if (dim < 3) + coord_ = v; + else + { + for (unsigned i = dim - 2; i < dim; ++i) + coord_[i] = round(v[j++]); + for (unsigned i = 2; i < dim; ++i, ++j) + coord_[i-j] = round(v[j]); + } } template <typename G, typename C> @@ -364,10 +370,16 @@ namespace mln point<G,C>::point(const algebra::vec<dim,float>& v) { unsigned j = 0; - for (unsigned i = dim - 2; i < dim; ++i) - coord_[i] = round(v[j++]); - for (unsigned i = 2; i < dim; ++i, ++j) - coord_[i-j] = round(v[j]); + //FIXME: to be improved while adding a conversion routine. + if (dim < 3) + coord_ = v; + else + { + for (unsigned i = dim - 2; i < dim; ++i) + coord_[i] = round(v[j++]); + for (unsigned i = 2; i < dim; ++i, ++j) + coord_[i-j] = round(v[j]); + } } -- 1.5.6.5
participants (1)
-
Guillaume Lazzara