Index: ChangeLog
from Nicolas Ballas <ballas(a)lrde.epita.fr>
New test for rle_class and sparse_image class.
* tests/core/sparse_image.cc: New.
* tests/core/rle_image.cc: New.
* tests/core/Makefile.am: Update
Makefile.am | 5 +++
rle_image.cc | 74 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
sparse_image.cc | 69 ++++++++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 148 insertions(+)
Index: tests/core/sparse_image.cc
--- tests/core/sparse_image.cc (revision 0)
+++ tests/core/sparse_image.cc (revision 0)
@@ -0,0 +1,69 @@
+#include <iostream>
+#include <oln/core/rle/rle_psite.hh>
+#include <oln/core/2d/image2d.hh>
+#include <oln/debug/print.hh>
+#include <oln/core/rle/rle_pset.hh>
+#include <oln/core/sparse/sparse_image.hh>
+#include <oln/core/encode/sparse_encode.hh>
+
+template <typename Ps>
+void test(const Ps& pset)
+{
+ typename Ps::fwd_piter it (pset);
+
+ for (it.start(); it.is_valid(); it.next())
+ std::cout << it.to_point() << std::endl;
+}
+
+template <typename Ps>
+void rtest(const Ps& pset)
+{
+ typename Ps::bkd_piter it (pset);
+
+ for (it.start(); it.is_valid(); it.next())
+ std::cout << it.to_point() << std::endl;
+}
+
+
+ template <typename I>
+ void print(I& ima)
+{
+ typename I::piter it (ima.points());
+
+ for (it.start(); it.is_valid(); it.next())
+ {
+ std::cout << (oln::point2d) it << std::endl;
+ std::cout << ima(it) << std::endl;
+ }
+}
+
+
+int main()
+{
+ oln::point2d p(0,1), q(2,2), r(3, 0);
+ oln::image2d<int> ima2d (1, 5);
+ oln::sparse_image<oln::point2d, int> sparse;
+ oln::sparse_image<oln::point2d, int> sparse2;
+
+ ima2d(oln::point2d(0, 4)) = 5;
+ oln::debug::print(ima2d);
+
+ std::vector<int> values;
+ int a =5;
+ values.push_back(a);
+ a = 6;
+ values.push_back(a);
+ a = 42;
+ values.push_back(a);
+
+ sparse.insert(q, 3, values);
+
+ oln::debug::print(sparse);
+
+ std::cout << "encode sparse" << std::endl;
+ sparse2 = sparse_encode(ima2d);
+
+ oln::debug::print(sparse2);
+
+ return 0;
+}
Index: tests/core/rle_image.cc
--- tests/core/rle_image.cc (revision 0)
+++ tests/core/rle_image.cc (revision 0)
@@ -0,0 +1,74 @@
+#include <iostream>
+#include <oln/core/rle/rle_psite.hh>
+#include <oln/core/rle/rle_image.hh>
+#include <oln/core/2d/image2d.hh>
+#include <oln/debug/print.hh>
+#include <oln/core/rle/rle_pset.hh>
+#include <oln/core/encode/rle_encode.hh>
+
+
+template <typename Ps>
+void test(const Ps& pset)
+{
+ typename Ps::fwd_piter it (pset);
+
+ for (it.start(); it.is_valid(); it.next())
+ std::cout << it.to_point() << std::endl;
+}
+
+template <typename Ps>
+void rtest(const Ps& pset)
+{
+ typename Ps::bkd_piter it (pset);
+
+ for (it.start(); it.is_valid(); it.next())
+ std::cout << it.to_point() << std::endl;
+}
+
+
+ template <typename I>
+ void print(I& ima)
+{
+ typename I::piter it (ima.points());
+
+ for (it.start(); it.is_valid(); it.next())
+ {
+ std::cout << (oln::point2d) it << std::endl;
+ std::cout << ima(it) << std::endl;
+ }
+}
+
+
+int main()
+{
+ oln::point2d p(0,1), q(2,2), r(3, 0);
+ oln::rle_pset<oln::point2d> my_set;
+ oln::rle_image<oln::point2d, int> rle;
+ oln::rle_image<oln::point2d, int> rle2;
+
+ my_set.insert(p, 5);
+ my_set.insert(q, 8);
+
+ rle.insert(p, 5, 4);
+ rle.insert(q, 8, 9);
+ std::cout << my_set.has(q) << std::endl;
+ test(my_set);
+ std::cout << "reverse" << std::endl;
+ rtest(my_set);
+ std::cout << "ima" << std::endl;
+ print(rle);
+
+ oln::debug::print(rle);
+ std::cout << rle.points().npoints() << std::endl;
+
+ std::cout << "encode rle" << std::endl;
+ oln::image2d<int> ima2d (1, 5);
+ ima2d(oln::point2d(0, 4)) = 5;
+
+ oln::debug::print(ima2d);
+
+ rle2 = rle_encode(ima2d);
+
+ oln::debug::print(rle2);
+ return 0;
+}
Index: tests/core/Makefile.am
--- tests/core/Makefile.am (revision 880)
+++ tests/core/Makefile.am (working copy)
@@ -19,6 +19,8 @@
check_PROGRAMS = \
+ rle_image \
+ sparse_image \
apply \
dpoint2d \
point2d \
@@ -30,6 +32,7 @@
window2d \
at
+
# Images and auxiliary structures.
dpoint2d_SOURCES = dpoint2d.cc
point2d_SOURCES = point2d.cc
@@ -39,6 +42,8 @@
npoints_SOURCES = npoints.cc
subset_SOURCES = subset.cc
window2d_SOURCES = window2d.cc
+rle_image_SOURCES = rle_image.cc
+sparse_image_SOURCES = sparse_image.cc
# Methods.
at_SOURCES = at.cc