URL:
https://svn.lrde.epita.fr/svn/oln/trunk/milena
ChangeLog:
2007-10-10 Matthieu Garrigues <garrigues(a)lrde.epita.fr>
Finalise hexagonal images.
* mln/core/hexa.hh,
* mln/core/hexa_piter.hh,
* mln/core/image2d_h.hh,
* mln/debug/println.hh,
* tests/hexa.cc,
* tests/image2d_h.cc: Fix.
---
mln/core/hexa.hh | 8 +++++---
mln/core/hexa_piter.hh | 20 ++++++++++----------
mln/core/image2d_h.hh | 9 ++-------
mln/debug/println.hh | 11 ++++-------
tests/hexa.cc | 4 +---
tests/image2d_h.cc | 20 +++++---------------
6 files changed, 27 insertions(+), 45 deletions(-)
Index: trunk/milena/tests/image2d_h.cc
===================================================================
--- trunk/milena/tests/image2d_h.cc (revision 1291)
+++ trunk/milena/tests/image2d_h.cc (revision 1292)
@@ -25,9 +25,9 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-/*! \file tests/hexa.cc
+/*! \file tests/image2d_h.cc
*
- * \brief Tests on mln::hexa
+ * \brief Tests on mln::image2d_h
*/
#include <mln/core/image2d_h.hh>
@@ -43,23 +43,13 @@
using namespace mln;
using value::int_u16;
- image2d_h<int_u16> h(2,7);
+ image2d_h<int_u16> h(50,50);
+
+ debug::println(h);
debug::iota(h);
debug::println(h);
-// image2d<int_u16> h(2,7);
-// debug::println(h);
-
trait::image::print(h, std::cout);
-
-
- // FIXME : to put into debug::println
- image2d_h<int_u16>::fwd_piter p(h.domain());
-
-// for_all(p)
-// {
-// std::cout << p << "->" << std::endl;
-// }
}
Index: trunk/milena/tests/hexa.cc
===================================================================
--- trunk/milena/tests/hexa.cc (revision 1291)
+++ trunk/milena/tests/hexa.cc (revision 1292)
@@ -50,9 +50,7 @@
debug::iota(ima);
trait::image::print(h, std::cout);
-
- // FIXME : to put into debug::println
- hexa<I>::fwd_piter p(h.domain());
+ hexa<I>::fwd_piter p(ima.domain());
for_all(p)
{
Index: trunk/milena/mln/debug/println.hh
===================================================================
--- trunk/milena/mln/debug/println.hh (revision 1291)
+++ trunk/milena/mln/debug/println.hh (revision 1292)
@@ -56,7 +56,7 @@
// generic version
template <typename S, typename I>
- void println(const S& b, const Image<I>& input_)
+ void println(const S&, const Image<I>& input_)
{
const I& input = exact(input_);
mln_piter(I) p(input.domain());
@@ -104,15 +104,12 @@
int r = 1;
int row_len = 1 + (b.max_col() - b.min_col()) / 2;
-// std::cout << "infos de ligne : " << b.min_col() <<
b.max_col() << std::endl;
-// std::cout << "largeur de ligne : " << row_len <<
std::endl;
for_all(p)
{
- //if (input.has(p))
- //std::cout << p << " ";
+ if (input.has(p))
std::cout << format(input(p)) << " ";
- //else
- // std::cout << " ";
+ else
+ std::cout << " ";
if (c >= row_len)
{
Index: trunk/milena/mln/core/hexa.hh
===================================================================
--- trunk/milena/mln/core/hexa.hh (revision 1291)
+++ trunk/milena/mln/core/hexa.hh (revision 1292)
@@ -135,7 +135,7 @@
/// FIXME : should it be in box2d_h?
/// Backward Point_Iterator associated type.
- /// typedef hexa_fwd_piter_<box2d> bkd_piter;
+ typedef hexa_bkd_piter_<box2d> bkd_piter;
/// Constructor without argument.
@@ -200,8 +200,8 @@
{
mln_precondition(! this->has_data());
box2d b_in = ima.bbox();
- box2d_h b = make::box2d_h(b_in.pmin()[0], b_in.pmin()[1] * 2 - 1,
- b_in.pmax()[0], b_in.pmax()[1] * 2 - 1);
+ box2d_h b = make::box2d_h(b_in.pmin()[0] * 2, b_in.pmin()[1],
+ b_in.pmax()[0] * 2, (b_in.pmax()[1] + 1) * 2 - 1);
this->data_ = new internal::data_< hexa<I> >(ima, b);
}
@@ -223,6 +223,7 @@
hexa<I>::operator()(const point2d_h& p) const
{
mln_precondition(this->has_data());
+ mln_precondition(this->has(p));
return this->data_->ima_(make::point2d(p[0] / 2, p[1] / 2));
}
@@ -231,6 +232,7 @@
hexa<I>::operator()(const point2d_h& p)
{
mln_precondition(this->has_data());
+ mln_precondition(this->has(p));
return this->data_->ima_(make::point2d(p[0] / 2, p[1] / 2));
}
Index: trunk/milena/mln/core/hexa_piter.hh
===================================================================
--- trunk/milena/mln/core/hexa_piter.hh (revision 1291)
+++ trunk/milena/mln/core/hexa_piter.hh (revision 1292)
@@ -63,9 +63,6 @@
hexa_fwd_piter_(const box2d& subset);
hexa_fwd_piter_(const box2d_h& subset);
- /// Dtor
- ~hexa_fwd_piter_();
-
/// Start an iteration.
void start();
@@ -76,6 +73,9 @@
private:
point2d_h p_;
+
+ //adaptee's box2d.
+ box2d box_adaptee_;
};
@@ -101,13 +101,14 @@
template <typename S>
hexa_fwd_piter_<S>::hexa_fwd_piter_(const box2d_h& b)
- : super_(adaptee_(*new box2d(make::box2d(b.pmin()[0] / 2, b.pmin()[1] / 2,
- b.pmax()[0] / 2 + 1, b.pmax()[1] / 2 + 1))))
- {
- }
+ :
+ box_adaptee_(make::box2d(b.pmin()[0] / 2,
+ b.pmin()[1] / 2,
+
+ b.pmax()[0] / 2 + b.pmax()[0] % 2,
+ b.pmax()[1] / 2)),
+ super_(adaptee_(box_adaptee_))
- template <typename S>
- hexa_fwd_piter_<S>::~hexa_fwd_piter_()
{
}
@@ -127,7 +128,6 @@
this->piter_.next();
p_[0] = this->piter_[0] * 2;
p_[1] = this->piter_[1] * 2 + this->piter_[0] % 2;
- std::cout << "next :" << p_ << std::endl;
}
template <typename S>
Index: trunk/milena/mln/core/image2d_h.hh
===================================================================
--- trunk/milena/mln/core/image2d_h.hh (revision 1291)
+++ trunk/milena/mln/core/image2d_h.hh (revision 1292)
@@ -65,16 +65,11 @@
template <typename V>
image2d_h<V>::image2d_h(int nrows, int ncols, unsigned bdr)
{
- std::cout << "Image2d_h Ctor " << nrows << "
"
- << ncols / 2 + 1 << std::endl;
-
- mln_assertion(ncols % 2 == 1);
+ mln_assertion(ncols % 2 == 0);
image2d<V> ima(nrows,
- ncols / 2 + 1,
+ ncols / 2,
bdr);
- debug::println(ima);
-
this->init_(ima);
}