* io/pnm/load.hh: add specials cases to handle vectorial type when
loading from ascii ppms.
---
milena/ChangeLog | 7 +++++++
milena/mln/io/pnm/load.hh | 43 +++++++++++++++++++++++++++++++++++++++----
2 files changed, 46 insertions(+), 4 deletions(-)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index b977679..391e5e8 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,3 +1,10 @@
+2012-06-05 Edwin Carlinet <carlinet(a)lrde.epita.fr>
+
+ Fix issues with loading ascii ppm.
+
+ * io/pnm/load.hh: add specials cases to handle vectorial type when
+ loading from ascii ppms.
+
2011-11-29 Guillaume Lazzara <z(a)lrde.epita.fr>
Fix the initialization of all global constants (ticket #43)
diff --git a/milena/mln/io/pnm/load.hh b/milena/mln/io/pnm/load.hh
index 46587df..88139ec 100644
--- a/milena/mln/io/pnm/load.hh
+++ b/milena/mln/io/pnm/load.hh
@@ -44,7 +44,9 @@
# include <mln/io/pnm/max_component.hh>
# include <mln/io/pnm/macros.hh>
+# include <mln/trait/value_.hh>
# include <mln/metal/is_a.hh>
+# include <mln/metal/bool.hh>
namespace mln
{
@@ -59,7 +61,13 @@ namespace mln
# ifndef MLN_INCLUDE_ONLY
template <typename I>
- void load_ascii_value(std::ifstream& file, I& ima);
+ void
+ load_ascii_value(std::ifstream& file, I& ima, metal::true_ is_scalar);
+
+ template <typename I>
+ void
+ load_ascii_value(std::ifstream& file, I& ima, metal::false_ is_scalar);
+
template <typename I>
void load_ascii_builtin(std::ifstream& file, I& ima);
@@ -73,7 +81,7 @@ namespace mln
void
load_ascii_dispatch(std::ifstream& file, I& ima, const
metal::bool_<true>&)
{
- load_ascii_value(file, ima);
+ load_ascii_value(file, ima, mlc_bool( mln_dim(mln_value(I)) == 1 ) () );
}
template <typename I>
@@ -158,20 +166,47 @@ namespace mln
file.read((char*)(&ima(p)), len);
}
- /// load_ascii for Milena value types.
+ /// load_ascii for Vectorial Milena value types.
template <typename I>
inline
- void load_ascii_value(std::ifstream& file, I& ima)
+ void
+ load_ascii_value(std::ifstream& file, I& ima, metal::false_)
+ {
+ enum { dim = mln_dim(mln_value(I)) };
+ typedef mln_equiv(mln_value_(I)) E;
+ typedef mln_equiv(trait::value_<E>::comp) T;
+ E v;
+ T x;
+
+ mln_fwd_piter(I) p(ima.domain());
+ for_all(p)
+ {
+ for (int i = 0; i<dim; ++i) {
+ file >> x;
+ v[i] = x;
+ }
+ ima(p) = v;
+ }
+ }
+
+ /// load_ascii for Scalar Milena value types
+ template <typename I>
+ inline
+ void
+ load_ascii_value(std::ifstream& file, I& ima, metal::true_)
{
mln_equiv(mln_value_(I)) c;
+
mln_fwd_piter(I) p(ima.domain());
for_all(p)
{
file >> c;
+ std::cout << c << std::endl;
ima(p) = c;
}
}
+
/// load_ascii for builtin value types.
template <typename I>
inline
--
1.7.2.5
Show replies by date