https://svn.lrde.epita.fr/svn/oln/trunk/milena
Index: ChangeLog
from Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
Rewrite the ostream op for grid points and dpoints.
* mln/core/concept/gpoint.hh,
* mln/core/concept/gdpoint.hh (operator<<): Rewrite.
It does not rely on to_vec anymore. Important note: the discrete
coordinates on a grid do not follow those of algebra vectors.
For example, we have:
point3d = (sli,row,col)
and
vec3d = (x, y, z)
where
x = row, y = col, and z = sli.
Now vectors are printed with a white space after every comma,
whereas there is no white space for discrete grid points and
dpoints. That is intuive since grid coordinates are integers
and vector coordinates are floating values (usually with a '.'
in them).
gdpoint.hh | 12 +++++++++---
gpoint.hh | 11 ++++++++---
2 files changed, 17 insertions(+), 6 deletions(-)
Index: mln/core/concept/gpoint.hh
--- mln/core/concept/gpoint.hh (revision 3491)
+++ mln/core/concept/gpoint.hh (working copy)
@@ -1,5 +1,5 @@
-// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory
-// (LRDE)
+// Copyright (C) 2007, 2008, 2009 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
@@ -39,6 +39,7 @@
# include <mln/value/concept/scalar.hh>
# include <mln/algebra/vec.hh>
# include <mln/util/ord.hh>
+# include <mln/debug/format.hh>
namespace mln
@@ -383,7 +384,11 @@
inline
std::ostream& operator<<(std::ostream& ostr, const Gpoint<P>&
p)
{
- return ostr << exact(p).to_vec();
+ enum { n = P::dim };
+ ostr << '(';
+ for (unsigned i = 0; i < n; ++i)
+ ostr << debug::format(exact(p)[i]) << (i == n - 1 ? ')' :
',');
+ return ostr;
}
template <typename P, typename D>
Index: mln/core/concept/gdpoint.hh
--- mln/core/concept/gdpoint.hh (revision 3491)
+++ mln/core/concept/gdpoint.hh (working copy)
@@ -1,5 +1,5 @@
-// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory
-// (LRDE)
+// Copyright (C) 2007, 2008, 2009 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
@@ -37,6 +37,8 @@
# include <mln/core/grids.hh>
# include <mln/trait/all.hh>
# include <mln/value/scalar.hh>
+# include <mln/debug/format.hh>
+
namespace mln
{
@@ -175,7 +177,11 @@
inline
std::ostream& operator<<(std::ostream& ostr, const Gdpoint<D>&
dp)
{
- return ostr << exact(dp).to_vec();
+ enum { n = D::dim };
+ ostr << '(';
+ for (unsigned i = 0; i < n; ++i)
+ ostr << debug::format(exact(dp)[i]) << (i == n - 1 ? ')' :
',');
+ return ostr;
}