
URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena ChangeLog: 2007-09-06 Matthieu Garrigues <garrigues.matthieu@lrde.epita.fr> add println_with_border * mln/debug/println.hh: add 3 function : println_with_border(const box2d& b, const Fast_Image<I>& input_) impl::println_with_border(const S&, const Fast_Image<I>& input_) impl::println_with_border(const box2d& b, const Fast_Image<I>& input_) * tests/println_with_border.cc: New. mln/debug/println.hh | 30 +++++++++++++++++++++++++++ tests/println_with_border.cc | 47 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 77 insertions(+) Index: trunk/milena/tests/println_with_border.cc =================================================================== --- trunk/milena/tests/println_with_border.cc (revision 0) +++ trunk/milena/tests/println_with_border.cc (revision 1082) @@ -0,0 +1,47 @@ +// Copyright (C) 2007 EPITA Research and Development Laboratory +// +// This file is part of the Olena Library. This library is free +// software; you can redistribute it and/or modify it under the terms +// of the GNU General Public License version 2 as published by the +// Free Software Foundation. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this library; see the file COPYING. If not, write to +// the Free Software Foundation, 51 Franklin Street, Fifth Floor, +// Boston, MA 02111-1307, USA. +// +// As a special exception, you may use this file as part of a free +// software library without restriction. Specifically, if other files +// instantiate templates or use macros or inline functions from this +// file, or you compile this file and link it with other files to +// produce an executable, this file does not by itself cause the +// resulting executable to be covered by the GNU General Public +// License. This exception does not however invalidate any other +// reasons why the executable file might be covered by the GNU General +// Public License. + +/*! \file tests/println_with_border.cc + * + * \brief Test on mln::debug::println_with_border. + */ + +#include <mln/core/image2d_b.hh> +#include <mln/level/fill.hh> +#include <mln/debug/println.hh> + + +using namespace mln; + + +int main() +{ + border::thickness = 3; + image2d_b<bool> msk(3, 3); + msk.at(1, 1) = true; + debug::println_with_border(msk); +} Index: trunk/milena/mln/debug/println.hh =================================================================== --- trunk/milena/mln/debug/println.hh (revision 1081) +++ trunk/milena/mln/debug/println.hh (revision 1082) @@ -67,6 +67,16 @@ std::cout << std::endl; } + template <typename S, typename I> + void println_with_border(const S&, const Fast_Image<I>& input_) + { + const I& input = exact(input_); + std::cout << input.ncells() << std::endl; + for (int i = 0; i < input.ncells(); i++) + std::cout << input.buffer()[i] << ' '; + std::cout << std::endl; + } + // 2D version template <typename I> void println(const box2d& b, const I& input) @@ -88,6 +98,20 @@ std::cout << std::endl; } + template <typename I> + void println_with_border(const box2d& b, const Fast_Image<I>& input_) + { + const I& input = exact(input_); + const int ncols = b.ncols() + 2 * input.border(); + for (int i = 0; i < input.ncells(); i++) + { + std::cout << input.buffer()[i] << ' '; + if (((i+1) % ncols) == 0) + std::cout << std::endl; + } + std::cout << std::endl; + } + } // end of namespace mln::debug::impl @@ -100,6 +124,12 @@ impl::println(exact(input).bbox(), exact(input)); } + template <typename I> + void println_with_border(const Fast_Image<I>& input) + { + impl::println_with_border(exact(input).bbox(), exact(input)); + } + # endif // ! MLN_INCLUDE_ONLY } // end of namespace mln::debug