Commit 757792db authored by Guillaume Lazzara's avatar Guillaume Lazzara
Browse files

Add box<>::merge.

	* mln/core/site_set/box.hh: New member 'merge()'.

	* tests/core/site_set/Makefile.am,
	* tests/core/site_set/box.cc: New test.
parent 852fd7f7
2010-02-16 Guillaume Lazzara <z@lrde.epita.fr>
Add box<>::merge.
* mln/core/site_set/box.hh: New member 'merge()'.
* tests/core/site_set/Makefile.am,
* tests/core/site_set/box.cc: New test.
2010-02-16 Guillaume Lazzara <z@lrde.epita.fr>
 
Rename image3d<>::nslices to image3d<>::nslis.
......@@ -152,6 +152,9 @@ namespace mln
/// Crop this bbox in order to fit in the reference box \p b.
void crop_wrt(const box<P>& b);
/// Merge inplace with another box.
void merge(const box<P>& b);
/// Return the size of this site set in memory.
std::size_t memory_size() const;
......@@ -210,6 +213,27 @@ namespace mln
pmax_.row() = ref.pmax().row();
}
template <typename P>
inline
void
box<P>::merge(const box<P>& b)
{
mln_precondition(is_valid());
if (! b.is_valid())
{
// no-op
return;
}
for (unsigned i = 0; i < P::dim; ++i)
{
if (b.pmin()[i] < pmin_[i])
pmin_[i] = b.pmin()[i];
if (b.pmax()[i] > pmax_[i])
pmax_[i] = b.pmax()[i];
}
}
template <typename P>
inline
P
......
......@@ -20,6 +20,7 @@
include $(top_srcdir)/milena/tests/tests.mk
check_PROGRAMS = \
box \
operators \
p_array \
p_complex \
......@@ -34,6 +35,7 @@ check_PROGRAMS = \
p_vaccess \
p_vertices
box_SOURCES = box.cc
operators_SOURCES = operators.cc
p_array_SOURCES = p_array.cc
p_complex_SOURCES = p_complex.cc
......
// Copyright (C) 2010 EPITA Research and Development Laboratory (LRDE)
//
// This file is part of Olena.
//
// Olena is free software: you can redistribute it and/or modify it under
// the terms of the GNU General Public License as published by the Free
// Software Foundation, version 2 of the License.
//
// Olena 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 Olena. If not, see <http://www.gnu.org/licenses/>.
//
// As a special exception, you may use this file as part of a free
// software project 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.
#include <mln/core/site_set/box.hh>
#include <mln/core/alias/box2d.hh>
#include <mln/core/alias/point2d.hh>
int main()
{
using namespace mln;
box2d
b1(point2d(0,0), point2d(3, 4)),
b2(point2d(-1,-1), point2d(4, 5));
b1.merge(b2);
mln_assertion(b1 == b2);
}
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