https://svn.lrde.epita.fr/svn/oln/trunk/milena
Index: ChangeLog
from Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
Various clean-ups + add line2d.
Clean-up functions.
* mln/fun/i2v,
* mln/fun/p2b,
* mln/fun/p2v,
* mln/fun/v2v: New directories.
* mln/fun/chess.hh: Rename as...
* mln/fun/p2b/chess.hh: New.
* mln/fun/to_enc.hh: Rename as...
* mln/fun/v2v/enc.hh: ...this.
(to_enc): Rename as...
(enc): ...this.
* mln/fun/all.hh: Rename as...
* mln/fun/i2v/all.hh: ...this.
* mln/core/point.hh,
* mln/core/window.hh,
* mln/core/dpoint.hh,
* mln/core/image2d_b.hh,
* mln/level/to_enc.hh: Update.
Clean-up windows.
* mln/core/win: New directory.
* mln/core/hline2d.hh: Rename as...
* mln/core/win/hline2d.hh: ...this.
* mln/core/rectangle2d.hh: Rename as...
* mln/core/win/rectangle2d.hh: ...this.
* mln/core/vline2d.hh: Rename as...
* mln/core/win/vline2d.hh: ...this.
* tests/median.cc,
* tests/fast_median.cc,
* tests/main.cc,
* tests/to_image.cc,
* tests/psubset.cc,
* tests/fimage.cc,
* tests/rectangle2d.cc,
* tests/cast_image.cc,
* tests/subimage.cc,
* tests/hmedian.cc,
* tests/erosion.cc,
* tests/naive_median.cc,
* mln/core/box2d.hh,
* mln/morpho/erosion.hh,
* mln/level/was.median.hh,
* mln/level/median.hh,
* mln/level/approx/median.hh: Update.
Clean-up metal.
* mlc/equal.hh: Rename as...
* mln/metal/equal.hh: ...this.
* mlc/same_coord.hh: Rename as...
* mln/metal/same_coord.hh: ...this.
* mlc/same_point.hh: Rename as...
* mln/metal/same_point.hh: ...this.
* mlc: Remove.
* mln/core/concept/generalized_point.hh: Update.
Light changes.
* TODO: Update.
* mln/core/dpoints_piter.hh
(dpoints_bkd_piter): New; fake.
* mln/core/fimage.hh: Add doc.
* mln/core/pvec.hh
(pvec_fwd_piter_, pvec_bkd_piter_): Move to...
* mln/core/pvec_piter.hh: ...this new file.
* mln/core/internal/fixme.hh: Add empty body.
New stuff.
* tests/line2d.cc: New.
* mln/pw/all.hh: New.
* mln/core/line2d.hh: New.
* mln/math: New.
* mln/math/min.hh: New.
* mln/math/abs.hh: New.
* mln/math/max.hh: New.
* mln/math/all.hh: New.
* mln/math/sign.hh: New.
* mln/draw: New.
* mln/draw/line.hh: New.
TODO | 3
mln/core/box2d.hh | 2
mln/core/concept/generalized_point.hh | 18 +--
mln/core/dpoint.hh | 2
mln/core/dpoints_piter.hh | 6 +
mln/core/fimage.hh | 3
mln/core/image2d_b.hh | 2
mln/core/internal/fixme.hh | 3
mln/core/line2d.hh | 199 ++++++++++++++++++++++++++++++++++
mln/core/point.hh | 2
mln/core/pvec.hh | 135 +----------------------
mln/core/pvec_piter.hh | 197 +++------------------------------
mln/core/win/hline2d.hh | 19 ++-
mln/core/win/rectangle2d.hh | 23 ++-
mln/core/win/vline2d.hh | 19 ++-
mln/core/window.hh | 2
mln/draw/line.hh | 93 +++++++++++++++
mln/fun/i2v/all.hh | 18 ++-
mln/fun/p2b/chess.hh | 13 +-
mln/fun/v2v/enc.hh | 17 +-
mln/level/approx/median.hh | 10 -
mln/level/median.hh | 8 -
mln/level/to_enc.hh | 4
mln/level/was.median.hh | 2
mln/math/abs.hh | 65 +++++++++++
mln/math/all.hh | 54 +++++++++
mln/math/max.hh | 62 ++++++++++
mln/math/min.hh | 62 ++++++++++
mln/math/sign.hh | 70 +++++++++++
mln/metal/equal.hh | 10 -
mln/metal/same_coord.hh | 14 +-
mln/metal/same_point.hh | 14 +-
mln/morpho/erosion.hh | 10 -
mln/pw/all.hh | 54 +++++++++
tests/cast_image.cc | 4
tests/erosion.cc | 4
tests/fast_median.cc | 6 -
tests/fimage.cc | 4
tests/hmedian.cc | 6 -
tests/line2d.cc | 64 ++++++++++
tests/main.cc | 2
tests/median.cc | 4
tests/naive_median.cc | 4
tests/psubset.cc | 4
tests/rectangle2d.cc | 6 -
tests/subimage.cc | 6 -
tests/to_image.cc | 4
47 files changed, 917 insertions(+), 416 deletions(-)
Index: tests/median.cc
--- tests/median.cc (revision 1039)
+++ tests/median.cc (working copy)
@@ -31,7 +31,7 @@
*/
#include <mln/core/image2d_b.hh>
-#include <mln/core/rectangle2d.hh>
+#include <mln/core/win/rectangle2d.hh>
#include <mln/io/load_pgm.hh>
#include <mln/io/save_pgm.hh>
@@ -48,7 +48,7 @@
using namespace mln;
using value::int_u8;
- rectangle2d rect(51, 51);
+ win::rectangle2d rect(51, 51);
border::thickness = 52;
image2d_b<int_u8>
Index: tests/fast_median.cc
--- tests/fast_median.cc (revision 1039)
+++ tests/fast_median.cc (working copy)
@@ -31,7 +31,7 @@
*/
#include <mln/core/image2d_b.hh>
-#include <mln/core/rectangle2d.hh>
+#include <mln/core/win/rectangle2d.hh>
#include <mln/io/load_pgm.hh>
#include <mln/io/save_pgm.hh>
@@ -80,7 +80,7 @@
using value::int_u8;
// {
-// rectangle2d rect(3, 3);
+// win::rectangle2d rect(3, 3);
// border::thickness = 4;
// image2d_b<int_u8> ima(3, 3);
// debug::iota(ima);
@@ -90,7 +90,7 @@
{
- rectangle2d rect(51, 51);
+ win::rectangle2d rect(51, 51);
border::thickness = 52;
image2d_b<int_u8>
Index: tests/line2d.cc
--- tests/line2d.cc (revision 0)
+++ tests/line2d.cc (revision 0)
@@ -0,0 +1,64 @@
+// 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/line2d.cc
+ *
+ * \brief Tests on mln::line2d.
+ */
+
+#include <iterator>
+
+#include <mln/core/image2d_b.hh>
+
+#include <mln/level/fill.hh>
+#include <mln/draw/line.hh>
+#include <mln/debug/println.hh>
+
+#include <mln/core/fimage.hh>
+#include <mln/pw/cst.hh>
+#include <mln/level/paste.hh>
+#include <mln/level/compare.hh>
+
+
+int main()
+{
+ using namespace mln;
+
+ point2d b = make::point2d(0,0), e = make::point2d(6,9);
+ line2d l(b, e);
+ mln_assertion(l.npoints() = 10);
+
+ image2d_b<bool> ima(10,10);
+ level::fill(ima, false);
+ draw::line(ima, b, e, true);
+
+ image2d_b<bool> ima2(10,10);
+ level::fill(ima2, false);
+ level::paste(pw::cst(true) | l, ima2);
+
+ mln_assertion(ima2 = ima);
+}
Index: tests/main.cc
--- tests/main.cc (revision 1039)
+++ tests/main.cc (working copy)
@@ -32,7 +32,7 @@
#include <mln/debug/println.hh>
#include <mln/core/window2d.hh>
-#include <mln/core/rectangle2d.hh>
+#include <mln/core/win/rectangle2d.hh>
#include <mln/core/neighb2d.hh>
Index: tests/to_image.cc
--- tests/to_image.cc (revision 1039)
+++ tests/to_image.cc (working copy)
@@ -33,7 +33,7 @@
#include <mln/core/image2d_b.hh>
#include <mln/core/window2d.hh>
#include <mln/core/psubset.hh>
-#include <mln/fun/chess.hh>
+#include <mln/fun/p2b/chess.hh>
#include <mln/level/compare.hh>
#include <mln/convert/to_image.hh>
@@ -57,7 +57,7 @@
0, 1, 0, // < center point
1, 0, 1 };
- image2d_b<bool> ima_X = convert::to_image(box_3x3 | fun::chess);
+ image2d_b<bool> ima_X = convert::to_image(box_3x3 | fun::p2b::chess);
window2d win_X = make::window2d(X);
mln_assertion(convert::to_image(win_X) = ima_X);
Index: tests/psubset.cc
--- tests/psubset.cc (revision 1039)
+++ tests/psubset.cc (working copy)
@@ -32,7 +32,7 @@
#include <mln/core/image2d_b.hh>
#include <mln/core/psubset.hh>
-#include <mln/fun/chess.hh>
+#include <mln/fun/p2b/chess.hh>
#include <mln/convert/to_image.hh>
@@ -41,5 +41,5 @@
using namespace mln;
box2d box_8x8 = make::box2d(8, 8);
- mln_assertion((box_8x8 | fun::chess).npoints() = 32);
+ mln_assertion((box_8x8 | fun::p2b::chess).npoints() = 32);
}
Index: tests/fimage.cc
--- tests/fimage.cc (revision 1039)
+++ tests/fimage.cc (working copy)
@@ -32,7 +32,7 @@
#include <mln/core/fimage.hh>
#include <mln/core/box2d.hh>
-#include <mln/fun/chess.hh>
+#include <mln/fun/p2b/chess.hh>
#include <mln/debug/println.hh>
@@ -40,5 +40,5 @@
{
using namespace mln;
- debug::println( fun::chess | make::box2d(8, 8) );
+ debug::println( fun::p2b::chess | make::box2d(8, 8) );
}
Index: tests/rectangle2d.cc
--- tests/rectangle2d.cc (revision 1039)
+++ tests/rectangle2d.cc (working copy)
@@ -27,10 +27,10 @@
/*! \file tests/rectangle2d.cc
*
- * \brief Tests on mln::rectangle2d.
+ * \brief Tests on mln::win/rectangle2d.
*/
-#include <mln/core/rectangle2d.hh>
+#include <mln/core/win/rectangle2d.hh>
@@ -39,7 +39,7 @@
using namespace mln;
const unsigned h = 3, w = 5;
- rectangle2d rec(h, w);
+ win::rectangle2d rec(h, w);
mln_assertion(rec.is_centered());
mln_assertion(rec.is_symmetric());
Index: tests/cast_image.cc
--- tests/cast_image.cc (revision 1039)
+++ tests/cast_image.cc (working copy)
@@ -31,7 +31,7 @@
*/
#include <mln/core/image2d_b.hh>
-#include <mln/fun/chess.hh>
+#include <mln/fun/p2b/chess.hh>
#include <mln/level/fill.hh>
#include <mln/debug/println.hh>
#include <mln/value/cast.hh>
@@ -42,7 +42,7 @@
using namespace mln;
image2d_b<bool> ima(8, 8);
- level::fill(ima, fun::chess);
+ level::fill(ima, fun::p2b::chess);
debug::println(ima);
debug::println( value::cast<int>(ima) );
}
Index: tests/subimage.cc
--- tests/subimage.cc (revision 1039)
+++ tests/subimage.cc (working copy)
@@ -32,7 +32,7 @@
#include <mln/core/image2d_b.hh>
#include <mln/core/subimage.hh>
-#include <mln/fun/chess.hh>
+#include <mln/fun/p2b/chess.hh>
#include <mln/debug/println.hh>
@@ -41,7 +41,7 @@
using namespace mln;
image2d_b<int> ima(8, 8);
- debug::println(ima | fun::chess);
+ debug::println(ima | fun::p2b::chess);
- // mln_assertion((box_8x8 | fun::chess).npoints() = 32);
+ // mln_assertion((box_8x8 | fun::p2b::chess).npoints() = 32);
}
Index: tests/hmedian.cc
--- tests/hmedian.cc (revision 1039)
+++ tests/hmedian.cc (working copy)
@@ -31,7 +31,7 @@
*/
#include <mln/core/image2d_b.hh>
-#include <mln/core/rectangle2d.hh>
+#include <mln/core/win/rectangle2d.hh>
#include <mln/io/load_pgm.hh>
#include <mln/io/save_pgm.hh>
@@ -55,9 +55,9 @@
out(lena.domain()),
ref(lena.domain());
- level::median(lena, rectangle2d(1, 101), ref);
+ level::median(lena, win::rectangle2d(1, 101), ref);
- level::median(lena, hline2d(101), out);
+ level::median(lena, win::hline2d(101), out);
io::save_pgm(out, "out.pgm");
// FIXME: mln_assertion(out = ref);
Index: tests/erosion.cc
--- tests/erosion.cc (revision 1039)
+++ tests/erosion.cc (working copy)
@@ -31,7 +31,7 @@
*/
#include <mln/core/image2d_b.hh>
-#include <mln/core/rectangle2d.hh>
+#include <mln/core/win/rectangle2d.hh>
#include <mln/io/load_pgm.hh>
#include <mln/io/save_pgm.hh>
@@ -51,7 +51,7 @@
using namespace mln;
using value::int_u8;
- rectangle2d rec(21, 21);
+ win::rectangle2d rec(21, 21);
border::thickness = 66;
image2d_b<int_u8>
Index: tests/naive_median.cc
--- tests/naive_median.cc (revision 1039)
+++ tests/naive_median.cc (working copy)
@@ -31,7 +31,7 @@
*/
#include <mln/core/image2d_b.hh>
-#include <mln/core/rectangle2d.hh>
+#include <mln/core/win/rectangle2d.hh>
#include <mln/io/load_pgm.hh>
#include <mln/io/save_pgm.hh>
@@ -46,7 +46,7 @@
int main()
{
- rectangle2d rec(51, 51);
+ win::rectangle2d rec(51, 51);
border::thickness = 52;
image2d_b<int_u8>
Index: TODO
--- TODO (revision 1039)
+++ TODO (working copy)
@@ -30,18 +30,19 @@
mlc into metal
+ look for "same_grid" etc.
+rectangle2d, hlin2d, etc -> core/win/
* clean-up
select_function in fun::internal::selector_p2? etc.
+value::cast(something) -> mln::cast_image or mln::fun::casted<F> etc.
* processing routines
reconstructions + their canvases
fast versions of level::fill and level::paste
-histogram class
sorting points w.r.t. their value (array of offsets, psites, points)
arith::inplace_plus et al.
linear:: for convolutions
Index: mln/pw/all.hh
--- mln/pw/all.hh (revision 0)
+++ mln/pw/all.hh (revision 0)
@@ -0,0 +1,54 @@
+// 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.
+
+#ifndef MLN_PW_ALL_HH
+# define MLN_PW_ALL_HH
+
+/*! \file mln/fun/pw/all.hh
+ *
+ * \brief File that includes all "point-wise" expression tools.
+ */
+
+
+namespace mln
+{
+
+ /*! Namespace of "point-wise" expression tools.
+ */
+ namespace pw {}
+
+} // end of namespace mln
+
+
+# include <mln/pw/value.hh>
+# include <mln/pw/cst.hh>
+# include <mln/pw/var.hh>
+
+# include <mln/fun/ops.hh>
+
+
+#endif // ! MLN_PW_ALL_HH
Index: mln/fun/i2v/all.hh
--- mln/fun/i2v/all.hh (revision 0)
+++ mln/fun/i2v/all.hh (working copy)
@@ -28,7 +28,7 @@
#ifndef MLN_FUN_ALL_HH
# define MLN_FUN_ALL_HH
-/*! \file mln/fun/all.hh
+/*! \file mln/fun/i2v/all.hh
*
* \brief FIXME.
*/
@@ -44,6 +44,9 @@
namespace fun
{
+ namespace i2v
+ {
+
template <typename T>
struct all : public Function_i2v< all<T> >
{
@@ -55,10 +58,12 @@
T t_;
};
+ } // end of namespace mln::fun::i2v
+
} // end of namespace mln::fun
template <typename T>
- fun::all<T> all(T t);
+ fun::i2v::all<T> all(T t);
# ifndef MLN_INCLUDE_ONLY
@@ -66,6 +71,9 @@
namespace fun
{
+ namespace i2v
+ {
+
template <typename T>
all<T>::all(T t)
: t_(t)
@@ -80,12 +88,14 @@
return t_;
}
+ } // end of namespace mln::fun::i2v
+
} // end of namespace mln::fun
template <typename T>
- fun::all<T> all(T t)
+ fun::i2v::all<T> all(T t)
{
- fun::all<T> tmp(t);
+ fun::i2v::all<T> tmp(t);
return tmp;
}
Index: mln/fun/p2b/chess.hh
--- mln/fun/p2b/chess.hh (revision 0)
+++ mln/fun/p2b/chess.hh (working copy)
@@ -25,10 +25,10 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef MLN_FUN_CHESS_HH
-# define MLN_FUN_CHESS_HH
+#ifndef MLN_FUN_P2B_CHESS_HH
+# define MLN_FUN_P2B_CHESS_HH
-/*! \file mln/fun/chess.hh
+/*! \file mln/fun/p2b/chess.hh
*
* \brief FIXME.
*/
@@ -43,6 +43,9 @@
namespace fun
{
+ namespace p2b
+ {
+
// FIXME: Doc!
struct chess_t : public Function_p2b< chess_t >
@@ -64,9 +67,11 @@
# endif // ! MLN_INCLUDE_ONLY
+ } // end of namespace mln::fun::p2b
+
} // end of namespace mln::fun
} // end of namespace mln
-#endif // ! MLN_FUN_CHESS_HH
+#endif // ! MLN_FUN_P2B_CHESS_HH
Index: mln/fun/v2v/enc.hh
--- mln/fun/v2v/enc.hh (revision 0)
+++ mln/fun/v2v/enc.hh (working copy)
@@ -25,10 +25,10 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef MLN_FUN_TO_ENC_HH
-# define MLN_FUN_TO_ENC_HH
+#ifndef MLN_FUN_V2V_ENC_HH
+# define MLN_FUN_V2V_ENC_HH
-/*! \file mln/fun/to_enc.hh
+/*! \file mln/fun/v2v/enc.hh
*
* \brief FIXME.
*/
@@ -42,10 +42,13 @@
namespace fun
{
+ namespace v2v
+ {
+
// FIXME: Doc!
template <typename V>
- struct to_enc : public Function_v2v< to_enc<V> >
+ struct enc : public Function_v2v< enc<V> >
{
typedef typename V::enc result;
result operator()(const V& v) const;
@@ -56,16 +59,18 @@
template <typename V>
typename V::enc
- to_enc<V>::operator()(const V& v) const
+ enc<V>::operator()(const V& v) const
{
return v.to_enc();
}
# endif // ! MLN_INCLUDE_ONLY
+ } // end of namespace mln::fun::v2v
+
} // end of namespace mln::fun
} // end of namespace mln
-#endif // ! MLN_FUN_TO_ENC_HH
+#endif // ! MLN_FUN_V2V_ENC_HH
Index: mln/core/dpoints_piter.hh
--- mln/core/dpoints_piter.hh (revision 1039)
+++ mln/core/dpoints_piter.hh (working copy)
@@ -112,6 +112,12 @@
};
+ // FIXME:
+ template <typename D>
+ class dpoints_bkd_piter : public internal::fixme
+ {};
+
+
# ifndef MLN_INCLUDE_ONLY
template <typename D>
Index: mln/core/fimage.hh
--- mln/core/fimage.hh (revision 1039)
+++ mln/core/fimage.hh (working copy)
@@ -102,6 +102,9 @@
+ /*! \brief FIXME
+ *
+ */
template <typename F, typename S>
fimage<F,S>
operator | (const Function_p2v<F>& f, const Point_Set<S>& ps)
Index: mln/core/point.hh
--- mln/core/point.hh (revision 1039)
+++ mln/core/point.hh (working copy)
@@ -35,7 +35,7 @@
# include <mln/core/concept/point.hh>
# include <mln/core/internal/coord_impl.hh>
-# include <mln/fun/all.hh>
+# include <mln/fun/i2v/all.hh>
namespace mln
Index: mln/core/pvec.hh
--- mln/core/pvec.hh (revision 1039)
+++ mln/core/pvec.hh (working copy)
@@ -36,7 +36,6 @@
# include <vector>
# include <mln/core/concept/point_set.hh>
-# include <mln/core/internal/fixme.hh>
# include <mln/accu/bbox.hh>
@@ -54,6 +53,8 @@
*
* \warning We have some troubles with point set comparison based on
* a call to npoints(). FIXME: Explain!
+ *
+ * \todo Make it work with P being a Point_Site.
*/
template <typename P>
class pvec : public Point_Set< pvec<P> >
@@ -61,7 +62,7 @@
public:
/// Point associated type.
- typedef mln_point(P) point;
+ typedef P point;
/// Point_Site associated type.
typedef P psite;
@@ -70,7 +71,7 @@
typedef pvec_fwd_piter_<P> fwd_piter;
/// Backward Point_Iterator associated type.
- typedef internal::fixme bkd_piter;
+ typedef pvec_bkd_piter_<P> bkd_piter;
/// Constructor.
pvec();
@@ -85,7 +86,7 @@
std::size_t npoints() const;
/// Give the exact bounding box.
- const box_<point>& bbox() const;
+ const box_<P>& bbox() const;
/// Append a point \p p.
pvec<P>& append(const P& p);
@@ -111,65 +112,8 @@
- /*! \brief Forward iterator on points of a pvec<P>.
- *
- */
- template <typename P>
- struct pvec_fwd_piter_
- {
- enum { dim = P::dim };
-
- /// Point_Site associated type.
- typedef P psite;
-
- /// Point associated type.
- typedef mln_point(P) point;
-
- /// Dpoint associated type.
- typedef mln_dpoint(P) dpoint;
-
- /// Coordinate associated type.
- typedef mln_coord(P) coord;
-
- /// Coordinate associated type.
- template <typename S>
- pvec_fwd_piter_(const Point_Set<S>& s);
-
- /// Give a hook to the point address.
- const point* pointer_() const;
-
- /// Read-only access to the \p i-th coordinate.
- coord operator[](unsigned i) const;
-
- /// Test if the iterator is valid.
- bool is_valid() const;
-
- /// Invalidate the iterator.
- void invalidate();
-
- /// Start an iteration.
- void start();
-
- /// Go to the next point.
- void next_();
-
- /// Convert the iterator into a point.
- operator P() const;
-
- protected:
- const std::vector<P>& vect_;
- point p_;
- };
-
-
-
-
# ifndef MLN_INCLUDE_ONLY
-
- // pvec<P>
-
-
template <typename P>
pvec<P>::pvec()
{
@@ -211,7 +155,7 @@
}
template <typename P>
- const box_<mln_point(P)>&
+ const box_<P>&
pvec<P>::bbox() const
{
mln_precondition(npoints() != 0);
@@ -251,73 +195,12 @@
return vect_[i];
}
-
-
- // pvec_fwd_piter_<P>
-
-
- template <typename P>
- template <typename S>
- pvec_fwd_piter_<P>::pvec_fwd_piter_(const Point_Set<S>& s)
- : vect_(exact(s).vect())
- {
- invalidate();
- }
-
- template <typename P>
- const mln_point(P)*
- pvec_fwd_piter_<P>::pointer_() const
- {
- return & p_;
- }
-
- template <typename P>
- mln_coord(P)
- pvec_fwd_piter_<P>::operator[](unsigned i) const
- {
- mln_precondition(i < dim);
- mln_precondition(is_valid());
- return p_[i];
- }
-
- template <typename P>
- bool
- pvec_fwd_piter_<P>::is_valid() const
- {
- return i < vect_.size();
- }
-
- template <typename P>
- void
- pvec_fwd_piter_<P>::invalidate()
- {
- i = vect_.size();
- }
-
- template <typename P>
- void
- pvec_fwd_piter_<P>::start()
- {
- i = 0;
- }
-
- template <typename P>
- void
- pvec_fwd_piter_<P>::next_()
- {
- ++i;
- }
-
- template <typename P>
- pvec_fwd_piter_<P>::operator P() const
- {
- mln_precondition(is_valid());
- return p_;
- }
-
# endif // ! MLN_INCLUDE_ONLY
} // end of namespace mln
+# include <mln/core/pvec_piter.hh>
+
+
#endif // ! MLN_CORE_PVEC_HH
Index: mln/core/pvec_piter.hh
--- mln/core/pvec_piter.hh (revision 1039)
+++ mln/core/pvec_piter.hh (working copy)
@@ -25,97 +25,26 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef MLN_CORE_PVEC_HH
-# define MLN_CORE_PVEC_HH
+#ifndef MLN_CORE_PVEC_PITER_HH
+# define MLN_CORE_PVEC_PITER_HH
-/*! \file mln/core/pvec.hh
+/*! \file mln/core/pvec_piter.hh
*
- * \brief Definition of a point set class based on std::vector.
+ * \brief Definition of point iterators on mln::pvec.
*/
-# include <vector>
-
-# include <mln/core/concept/point_set.hh>
+# include <mln/core/pvec.hh>
# include <mln/core/internal/fixme.hh>
-# include <mln/accu/bbox.hh>
namespace mln
{
- // Fwd decls.
- template <typename P> struct pvec_fwd_piter_;
- template <typename P> struct pvec_bkd_piter_;
-
-
- /*! \brief Point set class based on std::vector.
- *
- * This is a multi-set of points.
- *
- * \warning We have some troubles with point set comparison based on
- * a call to npoints(). FIXME: Explain!
- */
- template <typename P>
- class pvec : public Point_Set< pvec<P> >
- {
- public:
-
- /// Point associated type.
- typedef mln_point(P) point;
-
- /// Point_Site associated type.
- typedef P psite;
-
- /// Forward Point_Iterator associated type.
- typedef pvec_fwd_piter_<P> fwd_piter;
-
- /// Backward Point_Iterator associated type.
- typedef internal::fixme bkd_piter;
-
- /// Constructor.
- pvec();
-
- /// Constructor from a vector \p vect.
- pvec(const std::vector<P>& vect);
-
- /// Test is \p p belongs to this point set.
- bool has(const P& p) const;
-
- /// Give the number of points.
- std::size_t npoints() const;
-
- /// Give the exact bounding box.
- const box_<point>& bbox() const;
-
- /// Append a point \p p.
- pvec<P>& append(const P& p);
-
- /// Clear this set.
- void clear();
-
- /// Return the corresponding std::vector of points.
- const std::vector<P>& vect() const;
-
- /// Return the \p i-th point.
- const P& operator[](unsigned i) const;
-
- protected:
-
- std::vector<P> vect_;
- mutable accu::bbox<P> bb_;
- mutable bool bb_needs_update_;
-
- void update_bb_();
- // FIXME: Add invariant bb_.is_valid() <=> npoints() != 0
- };
-
-
-
/*! \brief Forward iterator on points of a pvec<P>.
*
*/
template <typename P>
- struct pvec_fwd_piter_
+ struct pvec_fwd_piter_ : public Point_Iterator< pvec_fwd_piter_<P> >
{
enum { dim = P::dim };
@@ -123,7 +52,7 @@
typedef P psite;
/// Point associated type.
- typedef mln_point(P) point;
+ typedef P point;
/// Dpoint associated type.
typedef mln_dpoint(P) dpoint;
@@ -136,7 +65,7 @@
pvec_fwd_piter_(const Point_Set<S>& s);
/// Give a hook to the point address.
- const point* pointer_() const;
+ const P* pointer_() const;
/// Read-only access to the \p i-th coordinate.
coord operator[](unsigned i) const;
@@ -158,103 +87,20 @@
protected:
const std::vector<P>& vect_;
- point p_;
+ unsigned i_;
+ P p_;
};
-
-# ifndef MLN_INCLUDE_ONLY
-
-
- // pvec<P>
-
-
+ // FIXME:
template <typename P>
- pvec<P>::pvec()
- {
- bb_needs_update_ = false;
- }
-
- template <typename P>
- pvec<P>::pvec(const std::vector<P>& vect)
- : vect_(vect)
- {
- bb_needs_update_ = true;
- }
-
- template <typename P>
- void
- pvec<P>::update_bb_()
- {
- bb_.clear();
- for (unsigned i = 0; i < vect_.size(); ++i)
- bb_.take(vect_[i]);
- bb_needs_update_ = false;
- }
-
- template <typename P>
- bool
- pvec<P>::has(const P& p) const
- {
- for (unsigned i = 0; i < vect_.size(); ++i)
- if (vect_[i] = p)
- return true;
- return false;
- }
-
- template <typename P>
- std::size_t
- pvec<P>::npoints() const
- {
- return vect_.size();
- }
-
- template <typename P>
- const box_<mln_point(P)>&
- pvec<P>::bbox() const
- {
- mln_precondition(npoints() != 0);
- if (bb_needs_update_)
- update_bb_();
- return bb_.to_value();
- }
-
- template <typename P>
- pvec<P>&
- pvec<P>::append(const P& p)
- {
- vect_.push_back(p);
- return *this;
- }
-
- template <typename P>
- void
- pvec<P>::clear()
- {
- vect_.clear();
- bb_needs_update_ = false;
- }
-
- template <typename P>
- const std::vector<P>&
- pvec<P>::vect() const
- {
- return vect_;
- }
-
- template <typename P>
- const P&
- pvec<P>::operator[](unsigned i) const
- {
- mln_precondition(i < npoints());
- return vect_[i];
- }
+ struct pvec_bkd_piter_ : internal::fixme
+ {};
- // pvec_fwd_piter_<P>
-
+# ifndef MLN_INCLUDE_ONLY
template <typename P>
template <typename S>
@@ -265,7 +111,7 @@
}
template <typename P>
- const mln_point(P)*
+ const P*
pvec_fwd_piter_<P>::pointer_() const
{
return & p_;
@@ -284,28 +130,31 @@
bool
pvec_fwd_piter_<P>::is_valid() const
{
- return i < vect_.size();
+ return i_ < vect_.size();
}
template <typename P>
void
pvec_fwd_piter_<P>::invalidate()
{
- i = vect_.size();
+ i_ = vect_.size();
}
template <typename P>
void
pvec_fwd_piter_<P>::start()
{
- i = 0;
+ i_ = 0;
+ if (is_valid())
+ p_ = vect_[i_];
}
template <typename P>
void
pvec_fwd_piter_<P>::next_()
{
- ++i;
+ ++i_;
+ p_ = vect_[i_];
}
template <typename P>
@@ -320,4 +169,4 @@
} // end of namespace mln
-#endif // ! MLN_CORE_PVEC_HH
+#endif // ! MLN_CORE_PVEC_PITER_HH
Index: mln/core/window.hh
--- mln/core/window.hh (revision 1039)
+++ mln/core/window.hh (working copy)
@@ -40,7 +40,7 @@
# include <mln/core/box.hh>
# include <mln/convert/to_dpoint.hh>
-# include <mln/fun/all.hh>
+# include <mln/fun/i2v/all.hh>
# include <mln/norm/infty.hh>
Index: mln/core/internal/fixme.hh
--- mln/core/internal/fixme.hh (revision 1039)
+++ mln/core/internal/fixme.hh (working copy)
@@ -45,7 +45,8 @@
*
* \internal
*/
- struct fixme;
+ struct fixme
+ {};
} // end of namespace mln::internal
Index: mln/core/box2d.hh
--- mln/core/box2d.hh (revision 1039)
+++ mln/core/box2d.hh (working copy)
@@ -44,7 +44,7 @@
/*! \brief Type alias for a box defined on the 2D square grid with
* integer coordinates.
*
- * \see mln::rectangle2d.
+ * \see mln::win::rectangle2d.
*/
typedef box_<point2d> box2d;
Index: mln/core/concept/generalized_point.hh
--- mln/core/concept/generalized_point.hh (revision 1039)
+++ mln/core/concept/generalized_point.hh (working copy)
@@ -31,9 +31,9 @@
/*! \file mln/core/concept/generalized_point.hh
* \brief Definition of the concept of mln::Generalized_Point.
*/
-# include <mlc/equal.hh>
-# include <mlc/same_point.hh>
-# include <mlc/same_coord.hh>
+# include <mln/metal/equal.hh>
+# include <mln/metal/same_point.hh>
+# include <mln/metal/same_coord.hh>
# include <mln/core/concept/object.hh>
# include <mln/core/internal/force_exact.hh>
@@ -225,10 +225,10 @@
template <typename Pl, typename Pr>
bool operator=(const Generalized_Point<Pl>& lhs, const
Generalized_Point<Pr>& rhs)
{
- // FIXME: mlc::same_grid<Pl, Pr>::check();
+ // FIXME: metal::same_grid<Pl, Pr>::check();
const Pl& lhs_ = internal::force_exact<Pl>(lhs);
const Pr& rhs_ = internal::force_exact<Pr>(rhs);
- mlc::same_point<Pl, Pr>::check();
+ metal::same_point<Pl, Pr>::check();
for (unsigned i = 0; i < Pl::dim; ++i)
if (lhs_[i] != rhs_[i])
return false;
@@ -238,7 +238,7 @@
template <typename Pl, typename Pr>
bool operator<(const Generalized_Point<Pl>& lhs, const
Generalized_Point<Pr>& rhs)
{
- // FIXME: mlc::same_grid<Pl, Pr>::check();
+ // FIXME: metal::same_grid<Pl, Pr>::check();
const Pl& lhs_ = internal::force_exact<Pl>(lhs);
const Pr& rhs_ = internal::force_exact<Pr>(rhs);
for (unsigned i = 0; i < Pl::dim; ++i)
@@ -254,9 +254,9 @@
mln_dpoint(Pl)
operator-(const Generalized_Point<Pl>& lhs, const
Generalized_Point<Pr>& rhs)
{
- mlc::equal<mln_dpoint(Pl), mln_dpoint(Pr)>::check();
- // FIXME: mlc::same_grid<Pl, Pr>::check();
- mlc::same_coord<Pl, Pr>::check();
+ metal::equal<mln_dpoint(Pl), mln_dpoint(Pr)>::check();
+ // FIXME: metal::same_grid<Pl, Pr>::check();
+ metal::same_coord<Pl, Pr>::check();
const Pl& lhs_ = internal::force_exact<Pl>(lhs);
const Pr& rhs_ = internal::force_exact<Pr>(rhs);
mln_dpoint(Pl) tmp;
Index: mln/core/dpoint.hh
--- mln/core/dpoint.hh (revision 1039)
+++ mln/core/dpoint.hh (working copy)
@@ -35,7 +35,7 @@
# include <mln/core/concept/dpoint.hh>
# include <mln/core/internal/coord_impl.hh>
-# include <mln/fun/all.hh>
+# include <mln/fun/i2v/all.hh>
namespace mln
Index: mln/core/win/vline2d.hh
--- mln/core/win/vline2d.hh (revision 0)
+++ mln/core/win/vline2d.hh (working copy)
@@ -25,12 +25,12 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef MLN_CORE_VLINE2D_HH
-# define MLN_CORE_VLINE2D_HH
+#ifndef MLN_CORE_WIN_VLINE2D_HH
+# define MLN_CORE_WIN_VLINE2D_HH
-/*! \file mln/core/vline2d.hh
+/*! \file mln/core/win/vline2d.hh
*
- * \brief Definition of the mln::vline2d window.
+ * \brief Definition of the mln::win::vline2d window.
*/
# include <mln/core/concept/window.hh>
@@ -42,6 +42,9 @@
namespace mln
{
+ namespace win
+ {
+
/*! \brief Vertical line window defined on the 2D square grid.
*
* An vline2d is centered and symmetrical; so its width is 1 and
@@ -54,7 +57,7 @@
* is defined with length = 5.
*/
struct vline2d : public Window< vline2d >,
- public internal::set_of_<dpoint2d>
+ public mln::internal::set_of_<dpoint2d>
{
/// Point associated type.
typedef point2d point;
@@ -70,7 +73,7 @@
/*! \brief Point_Iterator type to browse a vline such as: "for each row
* (decreasing), for each column (decreasing)."
*/
- typedef internal::fixme bkd_qiter;
+ typedef dpoints_bkd_piter<dpoint2d> bkd_qiter;
/*! \brief Same as fwd_qiter.
*/
@@ -171,8 +174,10 @@
# endif // ! MLN_INCLUDE_ONLY
+ } // end of namespace mln::win
+
} // end of namespace mln
-#endif // ! MLN_CORE_VLINE2D_HH
+#endif // ! MLN_CORE_WIN_VLINE2D_HH
Index: mln/core/win/hline2d.hh
--- mln/core/win/hline2d.hh (revision 0)
+++ mln/core/win/hline2d.hh (working copy)
@@ -25,12 +25,12 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef MLN_CORE_HLINE2D_HH
-# define MLN_CORE_HLINE2D_HH
+#ifndef MLN_CORE_WIN_HLINE2D_HH
+# define MLN_CORE_WIN_HLINE2D_HH
-/*! \file mln/core/hline2d.hh
+/*! \file mln/core/win/hline2d.hh
*
- * \brief Definition of the mln::hline2d window.
+ * \brief Definition of the mln::win::hline2d window.
*/
# include <mln/core/concept/window.hh>
@@ -42,6 +42,9 @@
namespace mln
{
+ namespace win
+ {
+
/*! \brief Horizontal line window defined on the 2D square grid.
*
* An hline2d is centered and symmetrical; so its height is 1 and
@@ -52,7 +55,7 @@
* is defined with length = 5.
*/
struct hline2d : public Window< hline2d >,
- public internal::set_of_<dpoint2d>
+ public mln::internal::set_of_<dpoint2d>
{
/// Point associated type.
typedef point2d point;
@@ -68,7 +71,7 @@
/*! \brief Point_Iterator type to browse a hline such as: "for each row
* (decreasing), for each column (decreasing)."
*/
- typedef internal::fixme bkd_qiter;
+ typedef dpoints_bkd_piter<dpoint2d> bkd_qiter;
/*! \brief Same as fwd_qiter.
*/
@@ -169,8 +172,10 @@
# endif // ! MLN_INCLUDE_ONLY
+ } // end of namespace mln::win
+
} // end of namespace mln
-#endif // ! MLN_CORE_HLINE2D_HH
+#endif // ! MLN_CORE_WIN_HLINE2D_HH
Index: mln/core/win/rectangle2d.hh
--- mln/core/win/rectangle2d.hh (revision 0)
+++ mln/core/win/rectangle2d.hh (working copy)
@@ -25,12 +25,12 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef MLN_CORE_RECTANGLE2D_HH
-# define MLN_CORE_RECTANGLE2D_HH
+#ifndef MLN_CORE_WIN_RECTANGLE2D_HH
+# define MLN_CORE_WIN_RECTANGLE2D_HH
-/*! \file mln/core/rectangle2d.hh
+/*! \file mln/core/win/rectangle2d.hh
*
- * \brief Definition of the mln::rectangle2d window.
+ * \brief Definition of the mln::win::rectangle2d window.
*/
# include <mln/core/concept/window.hh>
@@ -42,6 +42,9 @@
namespace mln
{
+ namespace win
+ {
+
/*! \brief Rectangular window defined on the 2D square grid.
*
* A rectangle2d is a 2D window with rectangular shape. It is
@@ -54,7 +57,7 @@
* is defined with height = 3 and width = 5.
*/
struct rectangle2d : public Window< rectangle2d >,
- public internal::set_of_<dpoint2d>
+ public mln::internal::set_of_<dpoint2d>
{
/// Point associated type.
typedef point2d point;
@@ -70,7 +73,7 @@
/*! \brief Point_Iterator type to browse a rectangle such as: "for each row
* (decreasing), for each column (decreasing)."
*/
- typedef internal::fixme bkd_qiter;
+ typedef dpoints_bkd_piter<dpoint2d> bkd_qiter;
/*! \brief Same as fwd_qiter.
*/
@@ -183,13 +186,15 @@
# endif // ! MLN_INCLUDE_ONLY
+ } // end of namespace mln::win
+
} // end of namespace mln
// when rectangle2d is involved, one surely also wants:
-# include <mln/core/hline2d.hh>
-# include <mln/core/vline2d.hh>
+# include <mln/core/win/hline2d.hh>
+# include <mln/core/win/vline2d.hh>
-#endif // ! MLN_CORE_RECTANGLE2D_HH
+#endif // ! MLN_CORE_WIN_RECTANGLE2D_HH
Index: mln/core/image2d_b.hh
--- mln/core/image2d_b.hh (revision 1039)
+++ mln/core/image2d_b.hh (working copy)
@@ -39,7 +39,7 @@
# include <mln/border/thickness.hh>
# include <mln/value/set.hh>
-# include <mln/fun/all.hh>
+# include <mln/fun/i2v/all.hh>
// FIXME:
Index: mln/core/line2d.hh
--- mln/core/line2d.hh (revision 0)
+++ mln/core/line2d.hh (revision 0)
@@ -0,0 +1,199 @@
+// 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.
+
+#ifndef MLN_CORE_LINE2D_HH
+# define MLN_CORE_LINE2D_HH
+
+/*! \file mln/core/line2d.hh
+ *
+ * \brief Definition of a point set class based on std::vector.
+ */
+
+# include <vector>
+
+# include <mln/core/concept/point_set.hh>
+# include <mln/core/pvec_piter.hh>
+# include <mln/core/box2d.hh>
+# include <mln/math/all.hh>
+
+
+namespace mln
+{
+
+
+ /*! \brief 2D line point set class.
+ */
+ class line2d : public Point_Set< line2d >
+ {
+ public:
+
+ /// Point associated type.
+ typedef point2d point;
+
+ /// Point_Site associated type.
+ typedef point2d psite;
+
+ /// Forward Point_Iterator associated type.
+ typedef pvec_fwd_piter_<point2d> fwd_piter;
+
+ /// Backward Point_Iterator associated type.
+ typedef pvec_bkd_piter_<point2d> bkd_piter;
+
+
+ /// Constructor from point \p beg to point \p end.
+ line2d(const point2d& beg, const point2d& end);
+
+
+ /// Test is \p p belongs to this point set.
+ bool has(const point2d& p) const;
+
+ /// Give the number of points.
+ std::size_t npoints() const;
+
+ /// Give the exact bounding box.
+ const box_<point2d>& bbox() const;
+
+ /// Append a point \p p.
+ line2d& append(const point2d& p);
+
+ /// Return the corresponding std::vector of points.
+ const std::vector<point2d>& vect() const;
+
+ /// Return the \p i-th point.
+ const point2d& operator[](unsigned i) const;
+
+ protected:
+
+ point2d beg_, end_;
+ std::vector<point2d> vect_;
+ box2d bb_;
+
+ void compute_();
+ };
+
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ line2d::line2d(const point2d& beg, const point2d& end)
+ : beg_(beg),
+ end_(end)
+ {
+ compute_();
+ }
+
+ void
+ line2d::compute_()
+ {
+ // vect_
+ dpoint2d dp = end_ - beg_;
+ int
+ srow = math::sign(dp.row()), drow = math::abs(dp.row()), ddrow = 2 * drow,
+ scol = math::sign(dp.col()), dcol = math::abs(dp.col()), ddcol = 2 * dcol,
+ row = beg_.row(),
+ col = beg_.row();
+ if ( dcol > drow )
+ {
+ int e = ddrow - dcol;
+ for (int i = 0; i < dcol; ++i)
+ {
+ vect_.push_back(make::point2d(row, col));
+ while (e >= 0)
+ {
+ row += srow;
+ e -= ddcol;
+ }
+ col += scol;
+ e += ddrow;
+ }
+ }
+ else
+ {
+ int e = ddcol - drow;
+ for (int i = 0; i < drow; ++i)
+ {
+ vect_.push_back(make::point2d(row, col));
+ while (e >= 0)
+ {
+ col += scol;
+ e -= ddrow;
+ }
+ row += srow;
+ e += ddcol;
+ }
+ }
+ vect_.push_back(make::point2d(row, col));
+ // bb_
+ bb_.pmin() = make::point2d(math::min(beg_.row(), end_.row()),
+ math::min(beg_.col(), end_.col()));
+ bb_.pmax() = make::point2d(math::max(beg_.row(), end_.row()),
+ math::max(beg_.col(), end_.col()));
+ }
+
+ bool
+ line2d::has(const point2d& p) const
+ {
+ if (! bb_.has(p))
+ return false;
+ // FIXME: Optimize!
+ for (unsigned i = 0; i < vect_.size(); ++i)
+ if (vect_[i] = p)
+ return true;
+ return false;
+ }
+
+ std::size_t
+ line2d::npoints() const
+ {
+ return vect_.size();
+ }
+
+ const box2d&
+ line2d::bbox() const
+ {
+ return bb_;
+ }
+
+ const std::vector<point2d>&
+ line2d::vect() const
+ {
+ return vect_;
+ }
+
+ const point2d&
+ line2d::operator[](unsigned i) const
+ {
+ mln_precondition(i < npoints());
+ return vect_[i];
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+} // end of namespace mln
+
+
+#endif // ! MLN_CORE_LINE2D_HH
Index: mln/math/min.hh
--- mln/math/min.hh (revision 0)
+++ mln/math/min.hh (revision 0)
@@ -0,0 +1,62 @@
+// 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.
+
+#ifndef MLN_MATH_MIN_HH
+# define MLN_MATH_MIN_HH
+
+/*! \file mln/math/min.hh
+ *
+ * \brief Define min routine.
+ */
+
+
+namespace mln
+{
+
+ namespace math
+ {
+
+ template <typename T>
+ T min(const T& v1, const T& v2);
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename T>
+ T min(const T& v1, const T& v2)
+ {
+ return v1 < v2 ? v1 : v2;
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::math
+
+} // end of namespace mln
+
+
+#endif // ! MLN_MATH_MIN_HH
Index: mln/math/abs.hh
--- mln/math/abs.hh (revision 0)
+++ mln/math/abs.hh (revision 0)
@@ -0,0 +1,65 @@
+// 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.
+
+#ifndef MLN_MATH_ABS_HH
+# define MLN_MATH_ABS_HH
+
+/*! \file mln/math/abs.hh
+ *
+ * \brief Define abs routine.
+ */
+
+# include <cmath>
+
+
+
+namespace mln
+{
+
+ namespace math
+ {
+
+ template <typename T>
+ T abs(const T& v);
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename T>
+ T abs(const T& v)
+ {
+ return std::abs(v);
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::math
+
+} // end of namespace mln
+
+
+#endif // ! MLN_MATH_ABS_HH
Index: mln/math/max.hh
--- mln/math/max.hh (revision 0)
+++ mln/math/max.hh (revision 0)
@@ -0,0 +1,62 @@
+// 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.
+
+#ifndef MLN_MATH_MAX_HH
+# define MLN_MATH_MAX_HH
+
+/*! \file mln/math/max.hh
+ *
+ * \brief Define max routine.
+ */
+
+
+namespace mln
+{
+
+ namespace math
+ {
+
+ template <typename T>
+ T max(const T& v1, const T& v2);
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename T>
+ T max(const T& v1, const T& v2)
+ {
+ return v1 > v2 ? v1 : v2;
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::math
+
+} // end of namespace mln
+
+
+#endif // ! MLN_MATH_MAX_HH
Index: mln/math/all.hh
--- mln/math/all.hh (revision 0)
+++ mln/math/all.hh (revision 0)
@@ -0,0 +1,54 @@
+// 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.
+
+#ifndef MLN_MATH_ALL_HH
+# define MLN_MATH_ALL_HH
+
+/*! \file mln/math/all.hh
+ *
+ * \brief File that includes all mathematical routines.
+ */
+
+
+namespace mln
+{
+
+ /*! Namespace of mathematical routines.
+ */
+ namespace math {}
+
+}
+
+
+# include <mln/math/sign.hh>
+# include <mln/math/abs.hh>
+# include <mln/math/min.hh>
+# include <mln/math/max.hh>
+
+
+
+#endif // ! MLN_MATH_ALL_HH
Index: mln/math/sign.hh
--- mln/math/sign.hh (revision 0)
+++ mln/math/sign.hh (revision 0)
@@ -0,0 +1,70 @@
+// 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.
+
+#ifndef MLN_MATH_SIGN_HH
+# define MLN_MATH_SIGN_HH
+
+/*! \file mln/math/sign.hh
+ *
+ * \brief Define sign routine.
+ */
+
+
+namespace mln
+{
+
+ namespace math
+ {
+
+ enum sign_t
+ {
+ negative = -1,
+ null = 0,
+ positive = +1
+ };
+
+
+ template <typename T>
+ sign_t sign(const T& v);
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename T>
+ sign_t sign(const T& v)
+ {
+ return v > 0 ? positive : (v < 0 ? negative : null);
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::math
+
+} // end of namespace mln
+
+
+#endif // ! MLN_MATH_SIGN_HH
Index: mln/draw/line.hh
--- mln/draw/line.hh (revision 0)
+++ mln/draw/line.hh (revision 0)
@@ -0,0 +1,93 @@
+// 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.
+
+#ifndef MLN_DRAW_LINE_HH
+# define MLN_DRAW_LINE_HH
+
+/*! \file mln/draw/line.hh
+ *
+ * \brief Draw a line in an image.
+ */
+
+# include <mln/core/concept/image.hh>
+# include <mln/core/line2d.hh>
+
+
+namespace mln
+{
+
+ namespace draw
+ {
+
+ /// Draw a line at level \p v in image \p ima between the points \p beg and \p end.
+ template <typename I>
+ void line(Image<I>& ima,
+ const mln_point(I)& beg, const mln_point(I)& end,
+ const mln_value(I)& v);
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ namespace impl
+ {
+
+ template <typename I>
+ void line(I& ima,
+ const point2d& beg, const point2d& end,
+ const mln_value(I)& v)
+ {
+ line2d l(beg, end);
+ mln_piter(line2d) p(l);
+ for_all(p)
+ ima(p) = v;
+ }
+
+ // FIXME: Overload.
+
+ } // end of namespace mln::draw::impl
+
+
+ // Facade.
+
+ template <typename I>
+ void line(Image<I>& ima,
+ const mln_point(I)& beg, const mln_point(I)& end,
+ const mln_value(I)& v)
+ {
+ mln_precondition(exact(ima).has_data());
+ mln_precondition(exact(ima).has(beg) && exact(ima).has(end));
+ impl::line(exact(ima), beg, end, v);
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::draw
+
+} // end of namespace mln
+
+
+#endif // ! MLN_DRAW_LINE_HH
Index: mln/metal/equal.hh
--- mln/metal/equal.hh (revision 1039)
+++ mln/metal/equal.hh (working copy)
@@ -25,14 +25,14 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef MLC_EQUAL_HH
-# define MLC_EQUAL_HH
+#ifndef MLN_METAL_EQUAL_HH
+# define MLN_METAL_EQUAL_HH
namespace mln
{
- namespace mlc
+ namespace metal
{
template <typename T1, typename T2>
@@ -47,9 +47,9 @@
};
- } // end of namespace mln::mlc
+ } // end of namespace mln::metal
} // end of namespace mln
-#endif // ! MLC_EQUAL_HH
+#endif // ! MLN_METAL_EQUAL_HH
Index: mln/metal/same_coord.hh
--- mln/metal/same_coord.hh (revision 1039)
+++ mln/metal/same_coord.hh (working copy)
@@ -25,27 +25,27 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef MLC_SAME_COORD_HH
-# define MLC_SAME_COORD_HH
+#ifndef MLN_METAL_SAME_COORD_HH
+# define MLN_METAL_SAME_COORD_HH
-# include <mlc/equal.hh>
+# include <mln/metal/equal.hh>
# include <mln/core/macros.hh>
namespace mln
{
- namespace mlc
+ namespace metal
{
template <typename T1, typename T2>
- struct same_coord : mlc::equal<mln_coord(T1), mln_coord(T2)>
+ struct same_coord : metal::equal<mln_coord(T1), mln_coord(T2)>
{
};
- } // end of namespace mln::mlc
+ } // end of namespace mln::metal
} // end of namespace mln
-#endif // ! MLC_SAME_COORD_HH
+#endif // ! MLN_METAL_SAME_COORD_HH
Index: mln/metal/same_point.hh
--- mln/metal/same_point.hh (revision 1039)
+++ mln/metal/same_point.hh (working copy)
@@ -25,27 +25,27 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef MLC_SAME_POINT_HH
-# define MLC_SAME_POINT_HH
+#ifndef MLN_METAL_SAME_POINT_HH
+# define MLN_METAL_SAME_POINT_HH
-# include <mlc/equal.hh>
+# include <mln/metal/equal.hh>
# include <mln/core/macros.hh>
namespace mln
{
- namespace mlc
+ namespace metal
{
template <typename T1, typename T2>
- struct same_point : mlc::equal<mln_point(T1), mln_point(T2)>
+ struct same_point : metal::equal<mln_point(T1), mln_point(T2)>
{
};
- } // end of namespace mln::mlc
+ } // end of namespace mln::metal
} // end of namespace mln
-#endif // ! MLC_SAME_POINT_HH
+#endif // ! MLN_METAL_SAME_POINT_HH
Index: mln/morpho/erosion.hh
--- mln/morpho/erosion.hh (revision 1039)
+++ mln/morpho/erosion.hh (working copy)
@@ -137,17 +137,17 @@
// --> call stage 2: dispatch w.r.t. the value kind
}
-# ifdef MLN_CORE_RECTANGLE2D_HH
+# ifdef MLN_CORE_WIN_RECTANGLE2D_HH
template <typename I, typename O>
- void erosion_wrt_win(const Image<I>& input, const rectangle2d& win,
Image<O>& output)
+ void erosion_wrt_win(const Image<I>& input, const win::rectangle2d&
win, Image<O>& output)
{
O tmp(exact(output).domain());
- morpho::erosion(input, hline2d(win.width()), tmp);
- morpho::erosion(tmp, vline2d(win.height()), output);
+ morpho::erosion(input, win::hline2d(win.width()), tmp);
+ morpho::erosion(tmp, win::vline2d(win.height()), output);
}
-# endif // MLN_CORE_RECTANGLE2D_HH
+# endif // MLN_CORE_WIN_RECTANGLE2D_HH
// ^
// |
Index: mln/level/was.median.hh
--- mln/level/was.median.hh (revision 1039)
+++ mln/level/was.median.hh (working copy)
@@ -133,7 +133,7 @@
// horizontal median
template <typename I, typename O>
- void hmedian(const I& input, const hline2d& win, O& output)
+ void hmedian(const I& input, const win::hline2d& win, O& output)
{
const int
Index: mln/level/median.hh
--- mln/level/median.hh (revision 1039)
+++ mln/level/median.hh (working copy)
@@ -36,7 +36,7 @@
# include <mln/core/concept/image.hh>
# include <mln/core/window2d.hh>
-# include <mln/core/hline2d.hh>
+# include <mln/core/win/hline2d.hh>
# include <mln/accu/median.hh>
# include <mln/canvas/sbrowsing.hh>
@@ -159,7 +159,7 @@
template <typename I, typename O>
- void median(const I& input, const hline2d& win, O& output)
+ void median(const I& input, const win::hline2d& win, O& output)
{
typedef mln_coord(I) coord;
const coord
@@ -212,10 +212,10 @@
// FIXME: Use transpose.
// template <typename I, typename O>
-// void median(const I& input, const vline2d& win, O& output)
+// void median(const I& input, const win::vline2d& win, O& output)
// {
-// median(, hline2d(win.length()), output);
+// median(, win::hline2d(win.length()), output);
// }
Index: mln/level/to_enc.hh
--- mln/level/to_enc.hh (revision 1039)
+++ mln/level/to_enc.hh (working copy)
@@ -35,7 +35,7 @@
*/
# include <mln/level/transform.hh>
-# include <mln/fun/to_enc.hh>
+# include <mln/fun/v2v/enc.hh>
namespace mln
@@ -61,7 +61,7 @@
void to_enc(const Image<I>& input, Image<O>& output)
{
mln_precondition(exact(output).domain() >= exact(input).domain());
- level::transform(input, fun::to_enc< mln_value(I) >(), output);
+ level::transform(input, fun::v2v::enc< mln_value(I) >(), output);
}
# endif // ! MLN_INCLUDE_ONLY
Index: mln/level/approx/median.hh
--- mln/level/approx/median.hh (revision 1039)
+++ mln/level/approx/median.hh (working copy)
@@ -34,7 +34,7 @@
*/
# include <mln/level/median.hh>
-# include <mln/core/rectangle2d.hh>
+# include <mln/core/win/rectangle2d.hh>
namespace mln
@@ -59,14 +59,14 @@
* \pre \p input and \p output have to be initialized.
*/
template <typename I, typename O>
- void median(const Image<I>& input, const rectangle2d& win,
+ void median(const Image<I>& input, const win::rectangle2d& win,
Image<O>& output);
# ifndef MLN_INCLUDE_ONLY
template <typename I, typename O>
- void median(const Image<I>& input_, const rectangle2d& win,
+ void median(const Image<I>& input_, const win::rectangle2d& win,
Image<O>& output_)
{
const I& input = exact(input_);
@@ -74,8 +74,8 @@
mln_assertion(output.domain() = input.domain());
O tmp(output.domain());
- level::median(input, hline2d(win.width()), tmp);
- level::median(tmp, vline2d(win.height()), output);
+ level::median(input, win::hline2d(win.width()), tmp);
+ level::median(tmp, win::vline2d(win.height()), output);
}
# endif // ! MLN_INCLUDE_ONLY