Commit 22c7ce91 authored by Matthieu Garrigues's avatar Matthieu Garrigues
Browse files

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.

git-svn-id: https://svn.lrde.epita.fr/svn/oln/trunk@1082 4aad255d-cdde-0310-9447-f3009e2ae8c0
parent c4f62af7
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.
2007-09-06 Thierry Geraud <thierry.geraud@lrde.epita.fr>
Add memcpy_ and memset_ for fast images; some fixes.
......
......@@ -67,6 +67,16 @@ namespace mln
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 @@ namespace mln
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 @@ namespace mln
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
......
// 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);
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment