Olena-patches
Threads by month
- ----- 2025 -----
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2007 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2006 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2005 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2004 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
November 2008
- 14 participants
- 266 discussions
https://svn.lrde.epita.fr/svn/oln/branches/cleanup-2008/milena
Index: ChangeLog
from Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
Import skeleton from matthieu's sandbox.
* mln/topo/is_simple_2d.hh: New.
* mln/morpho/skeleton_constrained.hh: New.
* tests/morpho/skeleton_constrained.cc: New.
* tests/morpho/Makefile.am: Update.
* img/small.pbm: New.
* img/fly.pbm: New.
* mln/win/multiple_size.hh (i_): Change type to signed.
(size_): Change return type to int to prevent warning.
(is_valid_, invalidate_): Fix the case of the iterator
construction is deferred.
img/fly.pbm | 5
mln/morpho/skeleton_constrained.hh | 177 +++++++++++------------------------
mln/topo/is_simple_2d.hh | 167 +++++++++++++--------------------
mln/win/multiple_size.hh | 12 +-
tests/morpho/Makefile.am | 3
tests/morpho/skeleton_constrained.cc | 104 ++++++++++++++++++++
6 files changed, 246 insertions(+), 222 deletions(-)
Index: tests/morpho/skeleton_constrained.cc
--- tests/morpho/skeleton_constrained.cc (revision 0)
+++ tests/morpho/skeleton_constrained.cc (revision 0)
@@ -0,0 +1,104 @@
+// Copyright (C) 2008 EPITA Research and Development Laboratory (LRDE)
+//
+// 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/morpho/skeleton_constrained.cc
+///
+/// Test on mln::morpho::skeleton_constrained.
+///
+
+#include <mln/core/image/image2d.hh>
+#include <mln/core/alias/neighb2d.hh>
+#include <mln/core/var.hh>
+#include <mln/value/int_u8.hh>
+
+#include <mln/make/dual_neighb.hh>
+#include <mln/topo/is_simple_2d.hh>
+#include <mln/morpho/skeleton_constrained.hh>
+
+#include <mln/io/pbm/load.hh>
+#include <mln/io/pbm/save.hh>
+#include <mln/level/fill.hh>
+#include <mln/debug/println.hh>
+#include <mln/debug/println_with_border.hh>
+
+#include <mln/pw/value.hh>
+#include <mln/core/image/image_if.hh>
+
+#include "tests/data.hh"
+
+
+namespace mln
+{
+
+ template <typename N>
+ void show_connectivity_numbers(const image2d<bool>& ima,
+ const N& nbh)
+ {
+ extension::adjust_fill(ima, nbh, false);
+
+ image2d<unsigned> when_true(ima.domain()), when_false(ima.domain());
+ mln_piter(box2d) p(ima.domain());
+ for_all(p)
+ {
+ when_true(p) = connectivity_number_2d(ima, nbh.foreground(), p, true);
+ when_false(p) = connectivity_number_2d(ima, nbh.background(), p, false);
+ }
+ debug::println("when true = ", when_true | pw::value(ima));
+ debug::println("when false = ", when_false | pw::value(ima));
+ }
+
+} // mln
+
+
+int main()
+{
+ using namespace mln;
+ using value::int_u8;
+
+ image2d<bool> pic;
+ io::pbm::load(pic, MLN_IMG_DIR "/tiny.pbm");
+
+ mln_VAR( nbh,
+ make::dual_neighb(pic, c4(), c8()) );
+
+ show_connectivity_numbers(pic, nbh);
+
+
+ image2d<bool> K(pic.domain());
+ level::fill(K, false);
+
+ image2d<int_u8> prior(pic.domain());
+ level::fill(prior, 1);
+
+ mln_VAR( skl,
+ morpho::skeleton_constrained(pic,
+ nbh, is_simple_2d_t(),
+ K, prior) );
+
+ debug::println("pic =", pic);
+ debug::println("skl =", skl);
+}
Index: tests/morpho/Makefile.am
--- tests/morpho/Makefile.am (revision 2895)
+++ tests/morpho/Makefile.am (working copy)
@@ -31,6 +31,7 @@
opening_area \
opening_height \
opening_volume \
+ skeleton_constrained \
thinning
# -------------- #
@@ -67,6 +68,8 @@
meyer_wst_SOURCES = meyer_wst.cc
+skeleton_constrained_SOURCES = skeleton_constrained.cc
+
combined_SOURCES = combined.cc
# --------------- #
Index: mln/topo/is_simple_2d.hh
--- mln/topo/is_simple_2d.hh (revision 2893)
+++ mln/topo/is_simple_2d.hh (working copy)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory
+// Copyright (C) 2008 EPITA Research and Development Laboratory (LRDE)
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -25,47 +25,59 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef MLN_SIMPLE_POINT_HH
-# define MLN_SIMPLE_POINT_HH
+#ifndef MLN_TOPO_IS_SIMPLE_2D_HH
+# define MLN_TOPO_IS_SIMPLE_2D_HH
-/*! \file simple_point.hh
- *
- * \brief is_simple_point tell if a point is simple or not (Cf
- * bertrand.07.chap).
- *
- */
+/// \file mln/topo/is_simple_2d.hh
+///
+/// Define the function is_simple_2d which tests if a point is simple
+/// or not (Cf bertrand.07.chap).
+
+#include <mln/core/concept/image.hh>
+#include <mln/core/concept/neighborhood.hh>
#include <mln/core/alias/point2d.hh>
-#include <mln/core/image/image2d.hh>
#include <mln/core/alias/neighb2d.hh>
+
namespace mln
{
-/*! Tell if a point is simple or not. A point of an object is simple
- * if in its c8 neiborhood, there is exactly one connected component of the
- * object, and only one connected component of the background
- * Examples : ( | == object, - = background)
- *
- * - - |
- * | P | Here p is simple in the c4 and c8 case.
- * | | |
- *
- * - | -
- * | P | Here p is never simple.
- * | | |
- *
- */
+ /// Test if a point is simple or not. A point of an object is simple
+ /// if in its c8 neiborhood, there is exactly one connected component of the
+ /// object, and only one connected component of the background
+ /// Examples : ( | == object, - = background)
+ ///
+ /// - - |
+ /// | P | Here p is simple in the c4 and c8 case.
+ /// | | |
+ ///
+ /// - | -
+ /// | P | Here p is never simple.
+ /// | | |
+
+ template<typename I, typename N>
+ bool
+ is_simple_2d(const Image<I>& ima, const Neighborhood<N>& nbh, const mln_psite(I)& p);
+
+
- bool is_simple_point(const image2d<bool>& ima, const neighb2d& nbh, const point2d& p);
+ struct is_simple_2d_t
+ {
+ template<typename I, typename N>
+ bool operator()(const Image<I>& ima,
+ const Neighborhood<N>& nbh,
+ const mln_psite(I)& p) const
+ {
+ return is_simple_2d(ima, nbh, p);
+ }
+ };
- unsigned nb_connexity2d(const image2d<bool>& ima, const neighb2d& nbh, const point2d& p);
- bool is_curve_extremum(const image2d<bool>& ima, unsigned nbh, const point2d& p);
# ifndef MLN_INCLUDE_ONLY
- static const unsigned char nb_connexity_c8[256] =
+ static const unsigned char connectivity_number_c8[256] =
{
0, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 2, 2, 1, 1,
1, 2, 1, 1, 1, 2, 1, 1, 2, 2, 1, 1, 2, 2, 1, 1,
@@ -88,7 +100,7 @@
1, 2, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
};
- static const unsigned char nb_connexity_c4[256] =
+ static const unsigned char connectivity_number_c4[256] =
{
0, 1, 1, 1, 1, 2, 1, 1, 1, 1, 2, 1, 2, 2, 2, 1,
1, 2, 2, 2, 1, 2, 1, 1, 2, 2, 3, 2, 2, 2, 2, 1,
@@ -111,96 +123,57 @@
1, 2, 2, 2, 1, 2, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1
};
- neighb2d int_to_neighb(unsigned i)
- {
- if (i == 8)
- return c8();
- if (i == 4)
- return c4();
- mln_assertion(0);
- return c4();
- }
- unsigned complement_neighb(unsigned i)
+ template<typename I, typename N>
+ inline
+ unsigned
+ connectivity_number_2d(const Image<I>& ima_, const Neighborhood<N>& nbh_,
+ const mln_psite(I)& p, bool b)
{
- if (i == 8)
- return 4;
- if (i == 4)
- return 8;
- mln_assertion(0);
- return 0;
- }
+ const I& ima = exact(ima_);
+ const N& nbh = exact(nbh_);
- unsigned nb_connexity2d(const image2d<bool>& ima, unsigned nbh, const point2d& p, bool object)
- {
unsigned res = 0;
- mln_bkd_niter_(neighb2d) n(c8() , p);
+ mln_bkd_niter(neighb2d) n(c8(), p);
for_all(n)
{
res = (res << 1);
- if (ima.domain().has(n) && ima(n) == object)
+ if (ima.domain().has(n) && ima(n) == b)
res = res | 1;
}
- if (nbh == 8)
- return nb_connexity_c8[res];
- else
- {
- mln_assertion(nbh == 4);
- return nb_connexity_c4[res];
- }
- }
-
- bool is_curve_extremum(const image2d<bool>& ima, unsigned nbh_i, const point2d& p_, unsigned deep)
- {
-// return false;
- unsigned cpt = 0;
- mln_site_(image2d<bool>) next = p_;
- mln_site_(image2d<bool>) p = next;
- mln_niter_(neighb2d) n(int_to_neighb(nbh_i) , p);
+ unsigned number;
- p = next;
- for_all(n)
+ switch (nbh.size())
{
- if (ima.domain().has(n) && ima(n) == true)
- {
- next = n;
- cpt++;
- }
+ case 4:
+ number = connectivity_number_c4[res];
+ break;
+ case 8:
+ number = connectivity_number_c8[res];
+ break;
+ default:
+ mln_assertion(0);
}
- if (cpt != 1)
- return false;
- for (unsigned i = 0; i < deep - 1; i++)
- {
- cpt = 0;
- p = next;
- for_all(n)
- {
- if (ima.domain().has(n) && ima(n) == true)
- {
- next = n;
- cpt++;
- }
- }
- if (cpt != 2)
- return false;
+ return number;
}
- return true;
- }
- bool is_simple_point2d(const image2d<bool>& ima, unsigned nbh, const point2d& p)
+ template<typename I, typename N>
+ inline
+ bool
+ is_simple_2d(const Image<I>& ima, const Neighborhood<N>& nbh_, const mln_psite(I)& p)
{
- mln_assertion(nbh == 4 || nbh == 8);
-
- return (nb_connexity2d(ima, nbh, p, true) == 1) &&
- (nb_connexity2d(ima, complement_neighb(nbh), p, false) == 1);
+ const N& nbh = exact(nbh_);
+ return
+ connectivity_number_2d(ima, nbh.foreground(), p, true ) == 1 &&
+ connectivity_number_2d(ima, nbh.background(), p, false) == 1;
}
# endif // MLN_INCLUDE_ONLY
} // end of namespace mln
-#endif // ! MLN_SIMPLE_POINT_HH
+#endif // ! MLN_TOPO_IS_SIMPLE_2D_HH
Index: mln/win/multiple_size.hh
--- mln/win/multiple_size.hh (revision 2895)
+++ mln/win/multiple_size.hh (working copy)
@@ -159,8 +159,8 @@
mln_psite(W) compute_p_() const;
private:
- unsigned i_;
- unsigned size_() const;
+ int i_;
+ int size_() const;
};
@@ -321,7 +321,7 @@
bool
multiple_size_qiter<n,W,F>::is_valid_() const
{
- return i_ < size_();
+ return i_ != -1 && i_ < size_();
}
template <unsigned n, typename W, typename F>
@@ -329,7 +329,7 @@
void
multiple_size_qiter<n,W,F>::invalidate_()
{
- i_ = size_();
+ i_ = -1;
}
template <unsigned n, typename W, typename F>
@@ -358,10 +358,10 @@
template <unsigned n, typename W, typename F>
inline
- unsigned
+ int
multiple_size_qiter<n,W,F>::size_() const
{
- return this->s_->size_around(*this->c_);
+ return int(this->s_->size_around(*this->c_));
}
# endif // ! MLN_INCLUDE_ONLY
Index: mln/morpho/skeleton_constrained.hh
--- mln/morpho/skeleton_constrained.hh (revision 2893)
+++ mln/morpho/skeleton_constrained.hh (working copy)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory
+// Copyright (C) 2008 EPITA Research and Development Laboratory (LRDE)
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -25,137 +25,97 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef MLN_SKELETON_HH
-# define MLN_SKELETON_HH
+#ifndef MLN_MORPHO_SKELETON_CONSTRAINED_HH
+# define MLN_MORPHO_SKELETON_CONSTRAINED_HH
-# include <iomanip>
-# include <iostream>
-# include <sstream>
-
-# include <mln/core/var.hh>
-
-# include <mln/core/image/image2d.hh>
-# include <mln/core/image/cast_image.hh>
-# include <mln/core/alias/neighb2d.hh>
+/// \file mln/morpho/skeleton_constrained.hh
+///
+/// Compute a skeleton under constraints.
+
+# include <mln/core/concept/image.hh>
+# include <mln/core/concept/neighborhood.hh>
# include <mln/core/site_set/p_queue_fast.hh>
# include <mln/core/site_set/p_priority.hh>
-
-# include <mln/value/int_u8.hh>
-# include <mln/arith/revert.hh>
-# include <mln/transform/distance.hh>
-
-# include <mln/make/w_window2d_int.hh>
-
+# include <mln/extension/adjust_fill.hh>
# include <mln/level/fill.hh>
-# include <mln/debug/println.hh>
-
-# include <mln/logical/not.hh>
-
-# include "simple_point.hh"
-
-#include <mln/make/w_window2d_int.hh>
-
-# include <mln/io/pgm/save.hh>
-# include <mln/io/pbm/save.hh>
namespace mln
{
- template <typename V>
- void save_state(const image2d<V>& ima)
+ namespace morpho
{
- static int id = 0;
- std::stringstream filename;
- std::cout << id << std::endl;
- filename << "skel_trace_" << std::setw(5) << std::setfill('0')
- << std::right << id++ << ".ppm";
+ template <typename I,
+ typename N, typename F,
+ typename K, typename R>
+ mln_ch_value(I, bool)
+ skeleton_constrained(const Image<I>& input,
+ const Neighborhood<N>& nbh, const F& is_simple,
+ const Image<K>& constraint, const Image<R>& priority);
- io::pbm::save(ima, filename.str());
- }
- image2d<bool> crest(const image2d<bool>& input,
- const image2d<value::int_u8>& dist_map,
- const neighb2d& nbh)
- {
- image2d<bool> is_crest;
- initialize(is_crest, input);
- level::fill(is_crest, false);
- mln_piter_(image2d<bool>) p(input.domain());
- mln_niter_(neighb2d) n(nbh, p);
- for_all(p)
- {
- if (!input(p) || dist_map(p) < 0)
- continue;
+# ifndef MLN_INCLUDE_ONLY
- unsigned nb_eq = 0;
- unsigned nb_gt = 0;
- for_all(n)
- if (input.domain().has(n))
+ template <typename I,
+ typename N, typename F,
+ typename K, typename R>
+ inline
+ mln_ch_value(I, bool)
+ skeleton_constrained(const Image<I>& input_,
+ const Neighborhood<N>& nbh_, const F& is_simple,
+ const Image<K>& constraint_, const Image<R>& priority_)
{
- if (dist_map(n) == dist_map(p))
- nb_eq++;
- else if (dist_map(n) > dist_map(p))
- nb_gt++;
- }
-
- if ((nb_gt == 1 && nb_eq == 0) ||
- (nb_gt == 0))
- is_crest(p) = true;
- }
- return is_crest;
- }
+ const I& input = exact(input_);
+ const N& nbh = exact(nbh_);
+ const K& constraint = exact(constraint_);
+ const R& priority = exact(priority_);
+ extension::adjust_fill(input, nbh, false);
- image2d<bool>
- skeleton_with_constraint(const image2d<bool>& input,
- unsigned nbh_i,
- const image2d<bool>& K,
- const image2d<value::int_u8>& priority)
- {
- mln_assertion(nbh_i == 4 || nbh_i == 8);
+ // FIXME: Tests!
- neighb2d nbh = int_to_neighb(nbh_i);
- image2d<bool> output;
- initialize(output, input);
+ typedef mln_psite(I) P;
+ typedef p_queue_fast<P> Q;
+ p_priority<mln_value(R), Q> q;
- typedef mln_site_(image2d<bool>) P;
- p_priority<value::int_u8, p_queue_fast<P> > q;
+ mln_ch_value(I, bool) output;
// Initialization.
{
- p_priority<value::int_u8, p_queue_fast<P> > q_tmp;
-
+ initialize(output, input);
level::fill(output, input);
- mln_piter_(image2d<bool>) p(input.domain());
+
+ mln_piter(I) p(input.domain());
for_all(p)
- if (!input(p) &&
- is_simple_point2d(input, nbh_i, p)) // p is a simple point of background
+ if ( input(p) == false )
+// if ( input(p) == false &&
+// is_simple(input, nbh, p) ) // p is a simple point of the background.
+ {
q.push(priority(p), p);
+ // std::cout << "push " << p << std::endl;
+ }
}
+ // std::cout << std::endl << "propagation..." << std::endl;
+
// Propagation.
{
P p;
- mln_niter_(neighb2d) n(nbh, p);
+ mln_niter(N) n(nbh, p);
while (! q.is_empty())
{
p = q.pop_front();
-
for_all(n)
if (output.domain().has(n) &&
- output(n) &&
- K(n) == false &&
- is_simple_point2d(output, nbh_i, n)
- // && // n is simple
- // !is_curve_extremum(output, nbh_i, n, 1)
- )
+ output(n) == true &&
+ constraint(n) == false &&
+ is_simple(output, nbh, n) )
{
- output(n) = false; // Remove n from object
- // save_state(output);
+ output(n) = false; // Remove n from object.
q.push(priority(n), n);
+ // std::cout << "push " << n << std::endl;
}
}
}
@@ -163,32 +123,11 @@
return output;
}
+# endif // ! MLN_INCLUDE_ONLY
- image2d<bool>
- skeleton(const image2d<bool>& input, unsigned nbh_i)
- {
- mln_assertion(nbh_i == 4 || nbh_i == 8);
- neighb2d nbh = int_to_neighb(nbh_i);
-
- int vals[] = { 0, 9, 0, 9, 0,
- 9, 6, 4, 6, 9,
- 0, 4, 0, 4, 0, // Values of distances.
- 9, 6, 4, 6, 9,
- 0, 9, 0, 9, 0 };
-
- image2d<value::int_u8> dist_map_n = transform::distance(value::int_u8(), logical::not_(input), nbh, make::w_window2d_int(vals));
- image2d<value::int_u8> dist_map = arith::revert(dist_map_n);
-
- io::pgm::save(dist_map, "distance.pgm");
- io::pgm::save(dist_map_n, "distance_n.pgm");
-
- // Make K
- image2d<bool> K = crest(input, dist_map_n, nbh);
- io::pbm::save(K, "K.pbm");
-
- return skeleton_with_constraint(input, nbh_i, K, dist_map);
- }
+ } // end of namespace mln::morpho
} // end of namespace mln
-#endif
+
+#endif // ! MLN_MORPHO_SKELETON_CONSTRAINED_HH
Index: img/small.pbm
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes on: img/small.pbm
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Index: img/fly.pbm
--- img/fly.pbm (revision 0)
+++ img/fly.pbm (revision 0)
@@ -0,0 +1,5 @@
+P4
+# CREATOR: XV version 3.10a-jumboFix+Enh of 20050501
+
+5 6
+����X�
\ No newline at end of file
1
0
https://svn.lrde.epita.fr/svn/oln/branches/cleanup-2008/milena/sandbox
Index: ChangeLog
from Alexandre Abraham <abraham(a)lrde.epita.fr>
Make the neighborhood energy count.
* markov/markov.hh: .
markov.hh | 45 +++++++++++++++++++++++++++++++--------------
1 file changed, 31 insertions(+), 14 deletions(-)
Index: markov/markov.hh
--- markov/markov.hh (revision 2894)
+++ markov/markov.hh (working copy)
@@ -9,8 +9,8 @@
namespace mln
{
- template <typename I, typename N>
- double compute_energy(const I& ima, const N& nbh, bool xi, const mln_site(I) &p)
+ template <typename I, typename O, typename N>
+ double compute_energy(const I& ima, const O& out, const N& nbh, bool xi, const mln_site(I) &p)
{
// Compute u(x,y)
double u;
@@ -25,19 +25,19 @@
mln_niter(N) n(nbh, p);
for_all(n)
- diff_sum += abs(ima(p) - ima(n));
+ {
+ diff_sum += abs(out(p) - out(n));
+ }
- return u + 10 * diff_sum;
+ return u + 100 * diff_sum;
}
template <typename I, typename N> // I == int_u8
- mln_ch_value(I, bool) markov(const Image<I>& ima_, const Neighborhood<N> nbh_, unsigned start_temp)
+ mln_ch_value(I, bool) markov(const Image<I>& ima_, const Neighborhood<N>& nbh_, unsigned start_temp)
{
const I &ima = exact(ima_);
const N &nbh = exact(nbh_);
- double epsilon = 0.001;
-
// mln_ch_value(I, bool) out(ima.domain()); // FIXME: generalize, we might not do a binarisation
mln_ch_value(I, bool) out = binarization::threshold(ima, 255 / 2); // FIXME : max
@@ -47,25 +47,42 @@
Random<bool> v_random(0, 1); // mettre max et min ?
Random<double> p_random(0., 1.); // idem
- while (temp > epsilon)
+ unsigned modifications = 42;
+ unsigned turn = 1;
+ bool gradient = false;
+
+ while (!gradient || modifications)
{
mln_piter(I) p(ima.domain());
+ modifications = 0;
for_all(p)
{
bool v = v_random.get();
- double u = compute_energy(ima, nbh, out(p), p);
- double up = compute_energy(ima, nbh, v, p);
-
- double d_u = abs(up - u);
+ double u = compute_energy(ima, out, nbh, out(p), p);
+ double up = compute_energy(ima, out, nbh, v, p);
+ double d_u = up - u;
double proba = exp(-d_u / temp);
- if (d_u < 0 || (p_random.get() > proba))
+ // std::cout << "Difference : " << d_u << std::endl;
+
+ if (d_u < 0 || !gradient && (p_random.get() < proba))
+ {
out(p) = v;
+ modifications ++;
+ }
}
temp = gtemp;
+ std::cout << "Turn : " << turn << " Modifs : " << modifications << " Temp : " << temp << std::endl;
+ turn ++;
+ if (!gradient && !modifications)
+ {
+ std::cout << "Gradient !" << std::endl;
+ modifications = 1;
+ gradient = true;
+ }
}
return out;
1
0
https://svn.lrde.epita.fr/svn/oln/branches/cleanup-2008/milena/sandbox
Index: ChangeLog
from Alexandre Abraham <abraham(a)lrde.epita.fr>
Fix some constants.
* markov/markov.hh: .
markov.hh | 49 ++++++++++++++++++-------------------------------
1 file changed, 18 insertions(+), 31 deletions(-)
Index: markov/markov.hh
--- markov/markov.hh (revision 2883)
+++ markov/markov.hh (working copy)
@@ -4,45 +4,30 @@
# include <cmath>
# include <random.hh>
# include <T_gen.hh>
+# include <mln/binarization/threshold.hh>
namespace mln
{
- /* I think we don't need it anymore...
- inline
- const neighb2d& neighb_h1()
- {
- static neighb2d it;
- if (it.size() == 0)
- {
- static const bool vals[] = { 0, 0, 0,
- 0, 0, 1,
- 0, 0, 0 };
- convert::from_to(vals, it);
- }
- return it;
- }
- */
-
template <typename I, typename N>
- double compute_energy(const I& ima, const N& nbh, bool xi, const mln_piter(I)& p)
+ double compute_energy(const I& ima, const N& nbh, bool xi, const mln_site(I) &p)
{
// Compute u(x,y)
double u;
if (xi)
u = (double) ima(p) / mln_max(mln_value(I));
else
- u = (double) (1 - ima(p)) / mln_max(mln_value(I));
+ u = 1. - (double) ima(p) / mln_max(mln_value(I));
- // u(x) is cst donc osef
+ // u(x) is cst so we don't care
- // u voisinage
+ double diff_sum = 0;
mln_niter(N) n(nbh, p);
for_all(n)
- // treat each point here ;), no need to make weird neighborhoods
- // make sth with |ima(p) - ima(n)|
- abs(ima(p) - ima(n));
+ diff_sum += abs(ima(p) - ima(n));
+
+ return u + 10 * diff_sum;
}
template <typename I, typename N> // I == int_u8
@@ -52,16 +37,17 @@
const N &nbh = exact(nbh_);
double epsilon = 0.001;
- mln_ch_value(I, bool) out(ima.domain()); // FIXME: generalize, we might not do a binarisation
- // G temp(start_temp);
- temperature_generator temp(start_temp, 0.99);
+
+ // mln_ch_value(I, bool) out(ima.domain()); // FIXME: generalize, we might not do a binarisation
+ mln_ch_value(I, bool) out = binarization::threshold(ima, 255 / 2); // FIXME : max
+
+ temperature_generator gtemp(start_temp, 0.99);
+ double temp = start_temp;
Random<bool> v_random(0, 1); // mettre max et min ?
Random<double> p_random(0., 1.); // idem
- // init(ima, out); ca empeche de compiloter
-
- while (temp < epsilon)
+ while (temp > epsilon)
{
mln_piter(I) p(ima.domain());
@@ -74,11 +60,12 @@
double d_u = abs(up - u);
- double proba = 0.5; // FIXME
+ double proba = exp(-d_u / temp);
- if (d_u < 0 or (p_random.get() > proba))
+ if (d_u < 0 || (p_random.get() > proba))
out(p) = v;
}
+ temp = gtemp;
}
return out;
1
0
URL: https://svn.lrde.epita.fr/svn/oln/branches/cleanup-2008/milena/sandbox
ChangeLog:
2008-11-18 Dalila Benboudjema <dalila(a)lrde.epita.fr>
Remove images.
* images/factures/facture.pbm: Remove.
* images/factures/facture2.pbm: Remove.
* images/factures/facture3.pbm: Remove.
* images/factures: Remove.
* images/photos/chavez.pbm: Remove.
* images/photos/family.pbm: Remove.
* images/photos/garden.pbm: Remove.
* images/photos/garden_crop.pbm: Remove.
* images/photos/revolution.pbm: Remove.
* images/photos/revolution2.pbm: Remove.
* images/photos: Remove.
* images: Remove.
---
0 files changed
Index: images/photos/garden_crop.pbm (deleted)
===================================================================
Index: images/photos/revolution.pbm (deleted)
===================================================================
Index: images/photos/revolution2.pbm (deleted)
===================================================================
Index: images/photos/chavez.pbm (deleted)
===================================================================
Index: images/photos/garden.pbm (deleted)
===================================================================
Index: images/photos/family.pbm (deleted)
===================================================================
Index: images/factures/facture.pbm (deleted)
===================================================================
Index: images/factures/facture2.pbm (deleted)
===================================================================
Index: images/factures/facture3.pbm (deleted)
===================================================================
1
0
18 Nov '08
https://svn.lrde.epita.fr/svn/oln/branches/cleanup-2008/milena
Index: ChangeLog
from Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
Cleanup optional methods in neighborhoods.
* tests/make/dual_neighb.cc: Test foreground and bg methods.
* mln/core/internal/neighborhood_base.hh
(neighborhood_extra_impl, neighborhood_impl): New.
(D): Change parameter into...
(W): ...this; that allows for factoring code here.
* mln/core/neighb.hh: Upgrade doc style.
Update inheritance.
(window, size, delta, dp): Move...
* mln/core/internal/neighborhood_base.hh
(neighborhood_impl): ...in this new class.
* mln/core/concept/neighborhood.hh: Upgrade doc style.
(operator==): New.
* mln/metal/ands.hh: New.
* mln/metal/all.hh: Update.
* mln/win/multiple_size.hh (n): New parameter.
(todo): New.
* mln/make/dual_neighb.hh: Upgrade doc style.
Update.
mln/core/concept/neighborhood.hh | 30 ++++--
mln/core/internal/neighborhood_base.hh | 148 +++++++++++++++++++++++++++++----
mln/core/neighb.hh | 80 ++---------------
mln/make/dual_neighb.hh | 15 +--
mln/metal/all.hh | 1
mln/metal/ands.hh | 69 +++++++++++++++
mln/win/multiple_size.hh | 135 +++++++++++++++---------------
tests/make/dual_neighb.cc | 3
8 files changed, 313 insertions(+), 168 deletions(-)
Index: tests/make/dual_neighb.cc
--- tests/make/dual_neighb.cc (revision 2892)
+++ tests/make/dual_neighb.cc (working copy)
@@ -59,6 +59,9 @@
mln_assertion( count(ima, make::dual_neighb(ima, c4(), c8()))
== c4().size() + c8().size() );
+ mln_assertion( make::dual_neighb(ima, c4(), c8()).foreground() == c4() );
+ mln_assertion( make::dual_neighb(ima, c4(), c8()).background() == c8() );
+
// We can observe that the neighboord is not restricted by the
// respective domains defined by ima(p) == false and ima(p) == true:
// for instance, at (0,0) we are in the *object* (ima(0,0) == true),
Index: mln/core/internal/neighborhood_base.hh
--- mln/core/internal/neighborhood_base.hh (revision 2892)
+++ mln/core/internal/neighborhood_base.hh (working copy)
@@ -1,4 +1,4 @@
-// Copyright (C) 2008 EPITA Research and Development Laboratory
+// Copyright (C) 2008 EPITA Research and Development Laboratory (LRDE)
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -28,49 +28,163 @@
#ifndef MLN_CORE_INTERNAL_NEIGHBORHOOD_BASE_HH
# define MLN_CORE_INTERNAL_NEIGHBORHOOD_BASE_HH
-/*! \file mln/core/internal/neighborhood_base.hh
- *
- * \brief Definition of a base class for neighborhood classes.
- */
+/// \file mln/core/internal/neighborhood_base.hh
+///
+/// Definition of a base class for neighborhood classes.
+///
+/// \todo Complete conditional implementation inheritance
+/// w.r.t. properties.
# include <mln/core/concept/neighborhood.hh>
+# include <mln/core/concept/window.hh>
namespace mln
{
+
+ // Forward declaration.
+ namespace win
+ {
+ template <unsigned n, typename W, typename F>
+ class multiple_size;
+ }
+
+
namespace internal
{
+ template <typename W, typename E>
+ struct neighborhood_extra_impl
+ : public Neighborhood<E>
+ {
+ };
- /*! A base class for neighborhood classes.
- *
- * \p D is a dpsite type.
- */
- template <typename D, typename E>
- struct neighborhood_base : public Neighborhood<E>
+ template <typename W, typename F, typename E>
+ struct neighborhood_extra_impl< win::multiple_size<2,W,F>, E >
+ : public Neighborhood<E>
{
- /// DPsite associated type.
- typedef D dpsite;
+ /// Give the foreground neighborhood in the case of a dual
+ /// neighborhood. For instance, with (object:c4, background:c8),
+ /// the result is c4.
+
+ neighb<W> foreground() const
+ {
+ W win = internal::force_exact<E>(*this).win().window_(1); // True, so object.
+ neighb<W> nbh(win);
+ return nbh;
+ }
+
+ /// Give the background neighborhood in the case of a dual
+ /// neighborhood. For instance, with (object:c4, background:c8),
+ /// the result is c8.
+
+ neighb<W> background() const
+ {
+ W win = internal::force_exact<E>(*this).win().window_(0); // False, so background.
+ neighb<W> nbh(win);
+ return nbh;
+ }
+
+ };
+
+
+
+
+ template <typename W, typename E>
+ struct neighborhood_impl : public neighborhood_extra_impl<W,E>
+ {
+ // Optional methods...
+
+ /// Give the neighborhood size, i.e., the number of elements it
+ /// contains.
+ unsigned size() const;
+
+ /// Give the maximum coordinate gap between the neighborhood
+ /// center and a neighboring point.
+ unsigned delta() const;
+
+ /// Give the maximum coordinate gap between the neighborhood
+ /// center and a neighboring point.
+ const mln_dpsite(W)& dp(unsigned i) const;
+
+ // end of Optional methods.
+ };
+
+
+ /// Base class for neighborhood implementation classes.
+ ///
+ /// \p W is the underlying window type.
+
+ template <typename W, typename E>
+ struct neighborhood_base : public neighborhood_impl<W,E>
+ {
+ /// Window associated type.
+ typedef W window;
+
+ /// Dpsite associated type.
+ typedef mln_dpsite(W) dpsite;
/// Psite associated type.
- typedef mln_psite(D) psite;
+ typedef mln_psite(W) psite;
/// Site associated type.
- typedef mln_site(D) site;
+ typedef mln_site(W) site;
protected:
neighborhood_base();
};
+
+
# ifndef MLN_INCLUDE_ONLY
- template <typename D, typename E>
+
+ // neighborhood_base
+
+ template <typename W, typename E>
+ inline
+ neighborhood_base<W,E>::neighborhood_base()
+ {
+ }
+
+
+ // neighborhood_impl
+
+ template <typename W, typename E>
+ inline
+ unsigned
+ neighborhood_impl<W,E>::size() const
+ {
+ mlc_is(mln_trait_window_size(W),
+ trait::window::size::fixed)::check();
+ return exact(this)->win().size();
+ }
+
+ template <typename W, typename E>
+ inline
+ unsigned
+ neighborhood_impl<W,E>::delta() const
+ {
+ mlc_is(mln_trait_window_support(W),
+ trait::window::support::regular)::check();
+ mlc_is_not(mln_trait_window_definition(W),
+ trait::window::definition::varying)::check();
+ return exact(this)->win().delta();
+ }
+
+ template <typename W, typename E>
inline
- neighborhood_base<D,E>::neighborhood_base()
+ const mln_dpsite(W)&
+ neighborhood_impl<W,E>::dp(unsigned i) const
{
+ mlc_is(mln_trait_window_support(W),
+ trait::window::support::regular)::check();
+ mlc_is(mln_trait_window_definition(W),
+ trait::window::definition::unique)::check();
+ return exact(this)->win().dp(i);
}
# endif // ! MLN_INCLUDE_ONLY
Index: mln/core/neighb.hh
--- mln/core/neighb.hh (revision 2892)
+++ mln/core/neighb.hh (working copy)
@@ -28,18 +28,14 @@
#ifndef MLN_CORE_NEIGHB_HH
# define MLN_CORE_NEIGHB_HH
-/*! \file mln/core/neighb.hh
- *
- * \brief Definition of a window-to-neighborhood adapter.
- *
- * \todo Introduce properties so that we can deal properly with
- * optional methods.
- *
- * \todo See if the impl of from_to is fine. What about removing the
- * origin? etc.
- */
+/// \file mln/core/neighb.hh
+///
+/// Definition of a window-to-neighborhood adapter.
+///
+///
+/// \todo See if the impl of from_to is fine. What about removing the
+/// origin? etc.
-# include <mln/core/concept/window.hh>
# include <mln/core/internal/neighborhood_base.hh>
# include <mln/core/internal/site_relative_iterator_base.hh>
@@ -53,17 +49,15 @@
template <typename W> class neighb_bkd_niter;
- /*! \brief Adapter class from window to neighborhood.
- */
+
+ /// Adapter class from window to neighborhood.
+
template <typename W>
- class neighb : public internal::neighborhood_base< mln_dpsite(W), neighb<W> >,
+ class neighb : public internal::neighborhood_base< W, neighb<W> >,
private mlc_is_a(W, Window)::check_t
{
public:
- /// Window associated type.
- typedef W window;
-
/// Forward site iterator associated type.
typedef neighb_fwd_niter<W> fwd_niter;
@@ -87,27 +81,11 @@
void change_window(const W& new_win);
- // Optional methods...
-
- /// Give the neighborhood size, i.e., the number of elements it
- /// contains.
- unsigned size() const;
-
- /// Give the maximum coordinate gap between the neighborhood
- /// center and a neighboring point.
- unsigned delta() const;
-
- /// Give the maximum coordinate gap between the neighborhood
- /// center and a neighboring point.
- const mln_dpsite(W)& dp(unsigned i) const;
-
- // end of Optional methods.
-
-
/// \internal Hook to the window.
W& hook_win_();
private:
+
W win_;
};
@@ -238,40 +216,6 @@
template <typename W>
inline
- unsigned
- neighb<W>::size() const
- {
- mlc_is(mln_trait_window_size(W),
- trait::window::size::fixed)::check();
- return win_.size();
- }
-
- template <typename W>
- inline
- unsigned
- neighb<W>::delta() const
- {
- mlc_is(mln_trait_window_support(W),
- trait::window::support::regular)::check();
- mlc_is_not(mln_trait_window_definition(W),
- trait::window::definition::varying)::check();
- return win_.delta();
- }
-
- template <typename W>
- inline
- const mln_dpsite(W)&
- neighb<W>::dp(unsigned i) const
- {
- mlc_is(mln_trait_window_support(W),
- trait::window::support::regular)::check();
- mlc_is(mln_trait_window_definition(W),
- trait::window::definition::unique)::check();
- return win_.dp(i);
- }
-
- template <typename W>
- inline
W&
neighb<W>::hook_win_()
{
Index: mln/core/concept/neighborhood.hh
--- mln/core/concept/neighborhood.hh (revision 2892)
+++ mln/core/concept/neighborhood.hh (working copy)
@@ -1,4 +1,5 @@
// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory
+// (LRDE)
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -28,9 +29,9 @@
#ifndef MLN_CORE_CONCEPT_NEIGHBORHOOD_HH
# define MLN_CORE_CONCEPT_NEIGHBORHOOD_HH
-/*! \file mln/core/concept/neighborhood.hh
- * \brief Definition of the concept of mln::Neighborhood.
- */
+/// \file mln/core/concept/neighborhood.hh
+///
+/// Definition of the concept of mln::Neighborhood.
# include <mln/core/concept/object.hh>
# include <mln/trait/windows.hh>
@@ -42,7 +43,9 @@
// Fwd decl.
template <typename E> struct Neighborhood;
- // Neighborhood category flag type.
+
+ /// Neighborhood category flag type.
+
template <>
struct Neighborhood<void>
{
@@ -50,11 +53,11 @@
};
- /*! \brief Base class for implementation classes that are neighborhoods.
- *
- * \see mln::doc::Neighborhood for a complete documentation of this
- * class contents.
- */
+ /// \brief Base class for implementation classes that are neighborhoods.
+ ///
+ /// \see mln::doc::Neighborhood for a complete documentation of this
+ /// class contents.
+
template <typename E>
struct Neighborhood : public Object<E>
{
@@ -78,6 +81,9 @@
+ template <typename L, typename R>
+ bool operator==(const Neighborhood<L>& lhs, const Neighborhood<R>& rhs);
+
template <typename N>
std::ostream&
@@ -108,6 +114,12 @@
}
+ template <typename L, typename R>
+ inline
+ bool operator==(const Neighborhood<L>& lhs, const Neighborhood<R>& rhs)
+ {
+ return exact(lhs).win() == exact(rhs).win();
+ }
template <typename N>
inline
Index: mln/metal/ands.hh
--- mln/metal/ands.hh (revision 0)
+++ mln/metal/ands.hh (revision 0)
@@ -0,0 +1,69 @@
+// Copyright (C) 2008 EPITA Research and Development Laboratory (LRDE)
+//
+// 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_METAL_ANDS_HH
+# define MLN_METAL_ANDS_HH
+
+/// \file mln/metal/ands.hh
+///
+/// Definition of a multiple-"and"s Boolean expression.
+
+# include <mln/metal/bool.hh>
+
+
+namespace mln
+{
+
+ namespace metal
+ {
+
+ /// Ands type.
+ template < typename E1,
+ typename E2,
+ typename E3,
+ typename E4 = true_,
+ typename E5 = true_,
+ typename E6 = true_,
+ typename E7 = true_,
+ typename E8 = true_ >
+ struct ands : bool_<( E1::value &&
+ E2::value &&
+ E3::value &&
+ E4::value &&
+ E5::value &&
+ E6::value &&
+ E7::value &&
+ E8::value )>
+ {};
+
+
+ } // end of namespace mln::metal
+
+} // end of namespace mln
+
+
+#endif // ! MLN_METAL_ANDS_HH
Index: mln/metal/all.hh
--- mln/metal/all.hh (revision 2892)
+++ mln/metal/all.hh (working copy)
@@ -54,6 +54,7 @@
# include <mln/metal/none.hh>
# include <mln/metal/abort.hh>
+# include <mln/metal/ands.hh>
# include <mln/metal/bexpr.hh>
# include <mln/metal/bool.hh>
# include <mln/metal/equal.hh>
Index: mln/make/dual_neighb.hh
--- mln/make/dual_neighb.hh (revision 2892)
+++ mln/make/dual_neighb.hh (working copy)
@@ -1,4 +1,4 @@
-// Copyright (C) 2008 EPITA Research and Development Laboratory
+// Copyright (C) 2008 EPITA Research and Development Laboratory (LRDE)
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -28,10 +28,9 @@
#ifndef MLN_MAKE_DUAL_NEIGHB_HH
# define MLN_MAKE_DUAL_NEIGHB_HH
-/*! \file mln/make/dual_neighb.hh
- *
- * \brief Routine to create a dual neighborhood.
- */
+/// \file mln/make/dual_neighb.hh
+///
+/// Routine to create a dual neighborhood.
# include <mln/core/concept/image.hh>
# include <mln/core/concept/neighborhood.hh>
@@ -47,7 +46,7 @@
{
template <typename I, typename N>
- neighb< win::multiple_size< mln_window(N), pw::value_<I> > >
+ neighb< win::multiple_size< 2, mln_window(N), pw::value_<I> > >
dual_neighb(const Image<I>& ima,
const Neighborhood<N>& nbh_true,
const Neighborhood<N>& nbh_false);
@@ -59,7 +58,7 @@
template <typename I, typename N>
inline
- neighb< win::multiple_size< mln_window(N), pw::value_<I> > >
+ neighb< win::multiple_size< 2, mln_window(N), pw::value_<I> > >
dual_neighb(const Image<I>& ima_,
const Neighborhood<N>& nbh_true_,
const Neighborhood<N>& nbh_false_)
@@ -73,7 +72,7 @@
const N& nbh_false = exact(nbh_false_);
mln_precondition(ima.has_data());
- typedef win::multiple_size< mln_window(N), pw::value_<I> > W;
+ typedef win::multiple_size< 2, mln_window(N), pw::value_<I> > W;
W win(pw::value(ima));
win.set_window(false, nbh_false.win()); // 0
win.set_window(true, nbh_true .win()); // 1
Index: mln/win/multiple_size.hh
--- mln/win/multiple_size.hh (revision 2892)
+++ mln/win/multiple_size.hh (working copy)
@@ -1,4 +1,4 @@
-// Copyright (C) 2008 EPITA Research and Development Laboratory
+// Copyright (C) 2008 EPITA Research and Development Laboratory (LRDE)
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -28,14 +28,16 @@
#ifndef MLN_WIN_MULTIPLE_SIZE_HH
# define MLN_WIN_MULTIPLE_SIZE_HH
-/*! \file mln/win/multiple_size.hh
- *
- * \brief Definition of a multiple-size window.
- */
+/// \file mln/win/multiple_size.hh
+///
+/// Definition of a multiple-size window.
+///
+/// \todo Use n for tests and code!!!
# include <mln/core/internal/window_base.hh>
# include <mln/core/internal/site_relative_iterator_base.hh>
# include <mln/util/array.hh>
+# include <mln/metal/ands.hh>
@@ -45,8 +47,8 @@
// Forward declarations.
namespace win
{
- template <typename W, typename F> class multiple_size;
- template <typename W, typename F> class multiple_size_qiter;
+ template <unsigned n, typename W, typename F> class multiple_size;
+ template <unsigned n, typename W, typename F> class multiple_size_qiter;
}
@@ -54,8 +56,8 @@
namespace trait
{
- template <typename W, typename F>
- struct window_< win::multiple_size<W,F> >
+ template <unsigned n, typename W, typename F>
+ struct window_< win::multiple_size<n,W,F> >
{
typedef trait::window::size::unknown size;
typedef trait::window::support::regular support;
@@ -69,12 +71,13 @@
namespace win
{
- template <typename W, typename F>
+ template <unsigned n, typename W, typename F>
class multiple_size
- : public internal::window_base< mln_dpsite(W), multiple_size<W,F> >,
+ : public internal::window_base< mln_dpsite(W), multiple_size<n,W,F> >,
- private metal::and_< mlc_is(mln_trait_window_size(W),
+ private metal::ands< mlc_bool(n > 1),
+ mlc_is(mln_trait_window_size(W),
trait::window::size::fixed),
mlc_is(mln_trait_window_support(W),
trait::window::support::regular) >::check_t
@@ -85,11 +88,11 @@
typedef mln_psite(W) psite;
typedef mln_site(W) site;
- typedef multiple_size< window<dpsite>, F > regular;
+ typedef multiple_size< n, window<dpsite>, F > regular;
- typedef multiple_size_qiter<W,F> fwd_qiter;
- typedef multiple_size_qiter<W,F> bkd_qiter;
- typedef multiple_size_qiter<W,F> qiter;
+ typedef multiple_size_qiter<n,W,F> fwd_qiter;
+ typedef multiple_size_qiter<n,W,F> bkd_qiter;
+ typedef multiple_size_qiter<n,W,F> qiter;
typedef W element;
@@ -126,19 +129,19 @@
};
- template <typename W, typename F>
+ template <unsigned n, typename W, typename F>
class multiple_size_qiter
- : public internal::site_relative_iterator_base< multiple_size<W,F>,
- multiple_size_qiter<W,F> >
+ : public internal::site_relative_iterator_base< multiple_size<n,W,F>,
+ multiple_size_qiter<n,W,F> >
{
- typedef multiple_size_qiter<W,F> self_;
- typedef internal::site_relative_iterator_base< multiple_size<W,F>, self_ > super_;
+ typedef multiple_size_qiter<n,W,F> self_;
+ typedef internal::site_relative_iterator_base< multiple_size<n,W,F>, self_ > super_;
public:
multiple_size_qiter();
template <typename P>
- multiple_size_qiter(const multiple_size<W,F>& w, const P& c);
+ multiple_size_qiter(const multiple_size<n,W,F>& w, const P& c);
/// Test the iterator validity.
bool is_valid_() const;
@@ -164,68 +167,68 @@
# ifndef MLN_INCLUDE_ONLY
- // win::multiple_size<W,F>
+ // win::multiple_size<n,W,F>
- template <typename W, typename F>
+ template <unsigned n, typename W, typename F>
inline
- multiple_size<W,F>::multiple_size()
+ multiple_size<n,W,F>::multiple_size()
: f_()
{
}
- template <typename W, typename F>
+ template <unsigned n, typename W, typename F>
inline
- multiple_size<W,F>::multiple_size(const F& f)
+ multiple_size<n,W,F>::multiple_size(const F& f)
: f_(f)
{
}
- template <typename W, typename F>
+ template <unsigned n, typename W, typename F>
inline
bool
- multiple_size<W,F>::is_empty() const
+ multiple_size<n,W,F>::is_empty() const
{
return win_.is_empty();
}
- template <typename W, typename F>
+ template <unsigned n, typename W, typename F>
inline
void
- multiple_size<W,F>::set_window(unsigned i, const W& win)
+ multiple_size<n,W,F>::set_window(unsigned i, const W& win)
{
mln_precondition(i == win_.nelements());
win_.append(win);
}
- template <typename W, typename F>
+ template <unsigned n, typename W, typename F>
inline
const W&
- multiple_size<W,F>::window_(unsigned i) const
+ multiple_size<n,W,F>::window_(unsigned i) const
{
mln_precondition(i < win_.nelements());
return win_[i];
}
- template <typename W, typename F>
+ template <unsigned n, typename W, typename F>
inline
unsigned
- multiple_size<W,F>::nwindows() const
+ multiple_size<n,W,F>::nwindows() const
{
return win_.nelements();
}
- template <typename W, typename F>
+ template <unsigned n, typename W, typename F>
inline
const F&
- multiple_size<W,F>::function() const
+ multiple_size<n,W,F>::function() const
{
return f_;
}
- template <typename W, typename F>
+ template <unsigned n, typename W, typename F>
inline
bool
- multiple_size<W,F>::is_centered() const
+ multiple_size<n,W,F>::is_centered() const
{
mln_precondition(win_.nelements() >= 1);
for (unsigned i = 0; i < win_.nelements(); ++i)
@@ -234,10 +237,10 @@
return true;
}
- template <typename W, typename F>
+ template <unsigned n, typename W, typename F>
inline
bool
- multiple_size<W,F>::is_symmetric() const
+ multiple_size<n,W,F>::is_symmetric() const
{
mln_precondition(win_.nelements() >= 1);
for (unsigned i = 0; i < win_.nelements(); ++i)
@@ -246,20 +249,20 @@
return true;
}
- template <typename W, typename F>
+ template <unsigned n, typename W, typename F>
inline
void
- multiple_size<W,F>::sym()
+ multiple_size<n,W,F>::sym()
{
mln_precondition(win_.nelements() >= 1);
for (unsigned i = 0; i < win_.nelements(); ++i)
win_[i].sym();
}
- template <typename W, typename F>
+ template <unsigned n, typename W, typename F>
inline
unsigned
- multiple_size<W,F>::delta() const
+ multiple_size<n,W,F>::delta() const
{
mln_precondition(win_.nelements() >= 1);
unsigned d = win_[0].delta();
@@ -272,20 +275,20 @@
return d;
}
- template <typename W, typename F>
+ template <unsigned n, typename W, typename F>
inline
unsigned
- multiple_size<W,F>::size_around(const mln_psite(W)& p) const
+ multiple_size<n,W,F>::size_around(const mln_psite(W)& p) const
{
mln_precondition(win_.nelements() >= 2);
mln_precondition(f_(p) < win_.nelements());
return win_[f_(p)].size();
}
- template <typename W, typename F>
+ template <unsigned n, typename W, typename F>
inline
const mln_dpsite(W)&
- multiple_size<W,F>::ith_dp_around(unsigned i, const mln_psite(W)& p) const
+ multiple_size<n,W,F>::ith_dp_around(unsigned i, const mln_psite(W)& p) const
{
mln_precondition(win_.nelements() >= 2);
mln_precondition(f_(p) < win_.nelements());
@@ -294,18 +297,18 @@
}
- // win::multiple_size_qiter<W,F>
+ // win::multiple_size_qiter<n,W,F>
- template <typename W, typename F>
+ template <unsigned n, typename W, typename F>
inline
- multiple_size_qiter<W,F>::multiple_size_qiter()
+ multiple_size_qiter<n,W,F>::multiple_size_qiter()
{
}
- template <typename W, typename F>
+ template <unsigned n, typename W, typename F>
template <typename P>
inline
- multiple_size_qiter<W,F>::multiple_size_qiter(const multiple_size<W,F>& w, const P& c)
+ multiple_size_qiter<n,W,F>::multiple_size_qiter(const multiple_size<n,W,F>& w, const P& c)
{
this->center_at(c);
// We have to first change the center so that 'invalidate' can
@@ -313,50 +316,50 @@
this->change_target(w);
}
- template <typename W, typename F>
+ template <unsigned n, typename W, typename F>
inline
bool
- multiple_size_qiter<W,F>::is_valid_() const
+ multiple_size_qiter<n,W,F>::is_valid_() const
{
return i_ < size_();
}
- template <typename W, typename F>
+ template <unsigned n, typename W, typename F>
inline
void
- multiple_size_qiter<W,F>::invalidate_()
+ multiple_size_qiter<n,W,F>::invalidate_()
{
i_ = size_();
}
- template <typename W, typename F>
+ template <unsigned n, typename W, typename F>
inline
void
- multiple_size_qiter<W,F>::do_start_()
+ multiple_size_qiter<n,W,F>::do_start_()
{
i_ = 0;
}
- template <typename W, typename F>
+ template <unsigned n, typename W, typename F>
inline
void
- multiple_size_qiter<W,F>::do_next_()
+ multiple_size_qiter<n,W,F>::do_next_()
{
++i_;
}
- template <typename W, typename F>
+ template <unsigned n, typename W, typename F>
inline
mln_psite(W)
- multiple_size_qiter<W,F>::compute_p_() const
+ multiple_size_qiter<n,W,F>::compute_p_() const
{
return *this->c_ + this->s_->ith_dp_around(i_, *this->c_);
}
- template <typename W, typename F>
+ template <unsigned n, typename W, typename F>
inline
unsigned
- multiple_size_qiter<W,F>::size_() const
+ multiple_size_qiter<n,W,F>::size_() const
{
return this->s_->size_around(*this->c_);
}
1
0
18 Nov '08
URL: https://svn.lrde.epita.fr/svn/oln/branches/cleanup-2008/milena
ChangeLog:
2008-11-18 Matthieu Garrigues <garrigues(a)lrde.epita.fr>
Convert the labeling canvas into a routine.
* mln/canvas/labeling.hh: .
* mln/labeling/level.hh: Update to use the routine.
---
canvas/labeling.hh | 226 ++++++++++++++++++++---------------------------------
labeling/level.hh | 8 -
2 files changed, 92 insertions(+), 142 deletions(-)
Index: branches/cleanup-2008/milena/mln/canvas/labeling.hh
===================================================================
--- branches/cleanup-2008/milena/mln/canvas/labeling.hh (revision 2891)
+++ branches/cleanup-2008/milena/mln/canvas/labeling.hh (revision 2892)
@@ -48,15 +48,34 @@
{
// General version.
+ template <typename I, typename N, typename F>
+ mln_ch_value(I, typename F::L)
+ labeling(const Image<I>& input, const Neighborhood<N>& nbh,
+ F& functor, typename F::L& nlabels);
- template <typename F>
- struct labeling
+
+# ifndef MLN_INCLUDE_ONLY
+
+
+ template <typename I>
+ static inline
+ mln_psite(I)
+ find_root(I& parent,
+ const mln_psite(I)& x)
{
- // Functor.
- F& f;
+ if (parent(x) == x)
+ return x;
+ else
+ return parent(x) = find_root(parent, parent(x));
+ }
+
+ template <typename I, typename N, typename F>
+ mln_ch_value(I, typename F::L)
+ labeling(const Image<I>& input, const Neighborhood<N>& nbh,
+ F& functor, typename F::L& nlabels)
+ {
+ trace::entering("canvas::labeling");
- typedef typename F::I I;
- typedef typename F::N N;
typedef typename F::L L;
typedef typename F::S S;
@@ -69,31 +88,78 @@
// Output.
mln_ch_value(I, L) output;
- L nlabels;
bool status;
- // Ctor.
- labeling(F& f);
-
- void init();
-
- void pass_1();
-
- void pass_2();
-
-
- // Auxiliary methods.
+ // Initialization. init();
+ {
+ initialize(deja_vu, functor.input);
+ mln::level::fill(deja_vu, false);
+ initialize(parent, functor.input);
+ initialize(output, functor.input);
+ mln::level::fill(output, L(literal::zero));
+ nlabels = 0;
+ functor.init(); // Client initialization.
+ }
- void make_set(const psite& p);
+ // First Pass. pass_1();
+ {
+ mln_fwd_piter(S) p(functor.s);
+ mln_niter(N) n(functor.nbh, p);
+ for_all(p) if (functor.handles(p))
+ {
+ // Make the set with p as root. make_set(p).
+ parent(p) = p;
+ functor.init_attr(p);
- bool is_root(const psite& p) const;
+ for_all(n)
+ if (functor.input.domain().has(n) && deja_vu(n))
+ {
+ if (functor.equiv(n, p))
+ {
+ // Put p as root. do_union(n, p);
+ psite r = find_root(parent, n);
+ if (r != p)
+ {
+ parent(r) = p;
+ functor.merge_attr(r, p);
+ }
+ }
+ else
+ functor.do_no_union(n, p);
+ }
+ deja_vu(p) = true;
+ }
+ }
- psite find_root(const psite& x);
+ // Second Pass. pass_2();
+ {
+ mln_bkd_piter(S) p(functor.s);
+ for_all(p) if (functor.handles(p))
+ {
+ if (parent(p) == p) // if p is root
+ {
+ if (functor.labels(p))
+ {
+ if (nlabels == mln_max(L))
+ {
+ status = false;
+ return output;
+ }
+ output(p) = ++nlabels;
+ }
+ }
+ else
+ output(p) = output(parent(p));
+ }
+ status = true;
- void do_union(const psite& n, const psite& p);
+ }
- };
+ trace::exiting("canvas::labeling");
+ return output;
+ }
+# endif // ! MLN_INCLUDE_ONLY
// Fastest version.
@@ -136,120 +202,6 @@
# ifndef MLN_INCLUDE_ONLY
- /*-------------------.
- | canvas::labeling. |
- `-------------------*/
-
- template <typename F>
- labeling<F>::labeling(F& f)
- : f(f)
- {
- trace::entering("canvas::labeling");
-
- init();
- f.init(); // Client initialization.
- pass_1();
- pass_2();
-
- trace::exiting("canvas::labeling");
- }
-
- template <typename F>
- void
- labeling<F>::init()
- {
- initialize(deja_vu, f.input);
- mln::level::fill(deja_vu, false);
- initialize(parent, f.input);
- initialize(output, f.input);
- mln::level::fill(output, L(literal::zero));
- nlabels = 0;
- }
-
- template <typename F>
- void
- labeling<F>::pass_1()
- {
- mln_fwd_piter(S) p(f.s);
- mln_niter(N) n(f.nbh, p);
- for_all(p) if (f.handles(p))
- {
- make_set(p);
- for_all(n)
- if (f.input.domain().has(n) && deja_vu(n))
- {
- if (f.equiv(n, p))
- do_union(n, p);
- else
- f.do_no_union(n, p);
- }
- deja_vu(p) = true;
- }
- }
-
- template <typename F>
- void
- labeling<F>::pass_2()
- {
- mln_bkd_piter(S) p(f.s);
- for_all(p) if (f.handles(p))
- {
- if (is_root(p))
- {
- if (f.labels(p))
- {
- if (nlabels == mln_max(L))
- {
- status = false;
- return;
- }
- output(p) = ++nlabels;
- }
- }
- else
- output(p) = output(parent(p));
- }
- status = true;
- }
-
- template <typename F>
- void
- labeling<F>::make_set(const psite& p)
- {
- parent(p) = p;
- f.init_attr(p);
- }
-
- template <typename F>
- bool
- labeling<F>::is_root(const psite& p) const
- {
- return parent(p) == p;
- }
-
- template <typename F>
- typename labeling<F>::psite
- labeling<F>::find_root(const psite& x)
- {
- if (parent(x) == x)
- return x;
- else
- return parent(x) = find_root(parent(x));
- }
-
- template <typename F>
- void
- labeling<F>::do_union(const psite& n, const psite& p)
- {
- psite r = find_root(n);
- if (r != p)
- {
- parent(r) = p;
- f.merge_attr(r, p);
- }
- }
-
-
/*---------------------------.
| canvas::labeling_fastest. |
`---------------------------*/
Index: branches/cleanup-2008/milena/mln/labeling/level.hh
===================================================================
--- branches/cleanup-2008/milena/mln/labeling/level.hh (revision 2891)
+++ branches/cleanup-2008/milena/mln/labeling/level.hh (revision 2892)
@@ -153,13 +153,11 @@
typedef level_functor<I,N,L> F;
F f(exact(input), val, exact(nbh));
- canvas::labeling<F> run(f);
-
- nlabels = run.nlabels;
- // FIXME: Handle run.status
+ mln_ch_value(I, L) output = canvas::labeling(input, nbh, f, nlabels);
+ // FIXME: Handle canvas status.
trace::exiting("labeling::impl::generic::level");
- return run.output;
+ return output;
}
} // end of namespace mln::labeling::impl::generic
1
0
https://svn.lrde.epita.fr/svn/oln/branches/cleanup-2008/milena
Index: ChangeLog
from Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
Cleanup tests make dual_neighb.
* tests/make/dual_neighb.cc: Upgrade doc style.
(count): Remove std cout echo.
(main): Augment commentary.
dual_neighb.cc | 16 +++++++++-------
1 file changed, 9 insertions(+), 7 deletions(-)
Index: tests/make/dual_neighb.cc
--- tests/make/dual_neighb.cc (revision 2890)
+++ tests/make/dual_neighb.cc (working copy)
@@ -1,4 +1,4 @@
-// Copyright (C) 2008 EPITA Research and Development Laboratory
+// Copyright (C) 2008 EPITA Research and Development Laboratory (LRDE)
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -25,10 +25,9 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-/*! \file tests/make/dual_neighb.cc
- *
- * \brief Tests on mln::make::dual_neighb.
- */
+/// \file tests/make/dual_neighb.cc
+///
+/// Tests on mln::make::dual_neighb.
#include <mln/make/dual_neighb.hh>
#include <mln/core/alias/neighb2d.hh>
@@ -44,7 +43,7 @@
unsigned c = 0;
for_all(p)
for_all(n)
- { std::cout << n << std::endl; ++c; }
+ ++c;
return c;
}
@@ -61,5 +60,8 @@
== c4().size() + c8().size() );
// We can observe that the neighboord is not restricted by the
- // respective domains defined by ima(p) == false and true.
+ // respective domains defined by ima(p) == false and ima(p) == true:
+ // for instance, at (0,0) we are in the *object* (ima(0,0) == true),
+ // thus the neighborhood is c4(), yet from p we browse neighbors n
+ // that are in the *background* (ima(n) == false).
}
1
0
https://svn.lrde.epita.fr/svn/oln/branches/cleanup-2008/milena
Index: ChangeLog
from Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
Fix warning in tests morpho elementary.
* tests/morpho/elementary/gradient.cc,
* tests/morpho/elementary/erosion.cc,
* tests/morpho/elementary/closing.cc,
* tests/morpho/elementary/top_hat.cc,
* tests/morpho/elementary/gradient_external.cc,
* tests/morpho/elementary/opening.cc,
* tests/morpho/elementary/dilation.cc,
* tests/morpho/elementary/gradient_internal.cc: Fix warning.
closing.cc | 2 +-
dilation.cc | 2 +-
erosion.cc | 2 +-
gradient.cc | 2 +-
gradient_external.cc | 2 +-
gradient_internal.cc | 2 +-
opening.cc | 2 +-
top_hat.cc | 2 +-
8 files changed, 8 insertions(+), 8 deletions(-)
Index: tests/morpho/elementary/gradient.cc
--- tests/morpho/elementary/gradient.cc (revision 2889)
+++ tests/morpho/elementary/gradient.cc (working copy)
@@ -62,7 +62,7 @@
}
image2d<bool> msk(3, 3, 0);
- level::fill(msk, pw::value(ima) >= pw::cst(5));
+ level::fill(msk, pw::value(ima) >= pw::cst(5u));
debug::println(msk);
{
mln_VAR(gra,
Index: tests/morpho/elementary/erosion.cc
--- tests/morpho/elementary/erosion.cc (revision 2889)
+++ tests/morpho/elementary/erosion.cc (working copy)
@@ -57,7 +57,7 @@
}
image2d<bool> msk(3, 3, 0);
- level::fill(msk, pw::value(ima) >= pw::cst(5));
+ level::fill(msk, pw::value(ima) >= pw::cst(5u));
debug::println(msk);
{
image2d<bool> ero = morpho::elementary::erosion(msk, c4());
Index: tests/morpho/elementary/closing.cc
--- tests/morpho/elementary/closing.cc (revision 2889)
+++ tests/morpho/elementary/closing.cc (working copy)
@@ -57,7 +57,7 @@
}
image2d<bool> msk(3, 3, 0);
- level::fill(msk, pw::value(ima) >= pw::cst(5));
+ level::fill(msk, pw::value(ima) >= pw::cst(5u));
debug::println(msk);
{
image2d<bool> clo = morpho::elementary::closing(msk, c4());
Index: tests/morpho/elementary/top_hat.cc
--- tests/morpho/elementary/top_hat.cc (revision 2889)
+++ tests/morpho/elementary/top_hat.cc (working copy)
@@ -56,7 +56,7 @@
debug::println( morpho::elementary::top_hat_self_complementary(ima, c4()) );
image2d<bool> msk(3, 3, 0);
- level::fill(msk, pw::value(ima) >= pw::cst(5));
+ level::fill(msk, pw::value(ima) >= pw::cst(5u));
debug::println(msk);
debug::println( morpho::elementary::top_hat_white(msk, c4()) );
Index: tests/morpho/elementary/gradient_external.cc
--- tests/morpho/elementary/gradient_external.cc (revision 2889)
+++ tests/morpho/elementary/gradient_external.cc (working copy)
@@ -62,7 +62,7 @@
}
image2d<bool> msk(3, 3, 0);
- level::fill(msk, pw::value(ima) >= pw::cst(5));
+ level::fill(msk, pw::value(ima) >= pw::cst(5u));
debug::println(msk);
{
mln_VAR(gra,
Index: tests/morpho/elementary/opening.cc
--- tests/morpho/elementary/opening.cc (revision 2889)
+++ tests/morpho/elementary/opening.cc (working copy)
@@ -57,7 +57,7 @@
}
image2d<bool> msk(3, 3, 0);
- level::fill(msk, pw::value(ima) >= pw::cst(5));
+ level::fill(msk, pw::value(ima) >= pw::cst(5u));
debug::println(msk);
{
image2d<bool> ope = morpho::elementary::opening(msk, c4());
Index: tests/morpho/elementary/dilation.cc
--- tests/morpho/elementary/dilation.cc (revision 2889)
+++ tests/morpho/elementary/dilation.cc (working copy)
@@ -57,7 +57,7 @@
}
image2d<bool> msk(3, 3, 0);
- level::fill(msk, pw::value(ima) >= pw::cst(5));
+ level::fill(msk, pw::value(ima) >= pw::cst(5u));
debug::println(msk);
{
image2d<bool> dil = morpho::elementary::dilation(msk, c4());
Index: tests/morpho/elementary/gradient_internal.cc
--- tests/morpho/elementary/gradient_internal.cc (revision 2889)
+++ tests/morpho/elementary/gradient_internal.cc (working copy)
@@ -62,7 +62,7 @@
}
image2d<bool> msk(3, 3, 0);
- level::fill(msk, pw::value(ima) >= pw::cst(5));
+ level::fill(msk, pw::value(ima) >= pw::cst(5u));
debug::println(msk);
{
mln_VAR(gra,
1
0
17 Nov '08
https://svn.lrde.epita.fr/svn/oln/branches/cleanup-2008/milena
Index: ChangeLog
from Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
Rename some graph-related files and classes.
* mln/util/internal/graph_edge.hh: Rename as...
* mln/util/edge.hh: ...this.
* mln/util/internal/graph_vertex.hh: Rename as...
* mln/util/vertex.hh: ...this.
* mln/util/all.hh: Update.
* mln/util/internal/graph_psite_base.hh: Rename as...
* mln/core/internal/graph_psite_base.hh: ...this.
* mln/util/internal/graph_vertex_psite.hh: Rename as...
* mln/core/site_set/p_vertices_psite.hh: ...this.
(internal::graph_vertex_psite): Rename as...
(p_vertices_psite): ...this.
* mln/util/internal/graph_edge_psite.hh: Rename as...
* mln/core/site_set/p_edges_psite.hh: ...this.
(internal::graph_edge_psite): Rename as...
(p_edges_psite): ...this.
* mln/util/internal/graph_iter.hh,
* mln/util/internal/graph_base.hh,
* mln/util/internal/graph_iter_base.hh,
* mln/core/site_set/p_vertices.hh,
* mln/core/site_set/p_edges.hh,
* mln/core/image/line_graph_neighborhood_piter.hh,
* mln/core/image/line_graph_window_piter.hh,
* mln/core/image/line_graph_elt_window.hh,
* mln/core/image/line_graph_elt_neighborhood.hh,
* mln/core/image/graph_window_piter.hh,
* mln/core/image/graph_neighborhood_piter.hh,
* mln/core/image/graph_elt_neighborhood.hh,
* mln/core/image/graph_elt_window.hh: Update.
core/image/graph_elt_neighborhood.hh | 6 -
core/image/graph_elt_window.hh | 6 -
core/image/graph_neighborhood_piter.hh | 4 -
core/image/graph_window_piter.hh | 4 -
core/image/line_graph_elt_neighborhood.hh | 7 +-
core/image/line_graph_elt_window.hh | 7 +-
core/image/line_graph_neighborhood_piter.hh | 4 -
core/image/line_graph_window_piter.hh | 4 -
core/internal/graph_psite_base.hh | 24 ++-----
core/site_set/p_edges.hh | 7 +-
core/site_set/p_edges_psite.hh | 41 +++++--------
core/site_set/p_vertices.hh | 10 +--
core/site_set/p_vertices_psite.hh | 41 +++++--------
util/all.hh | 10 +--
util/edge.hh | 29 ++++++---
util/internal/graph_base.hh | 9 +-
util/internal/graph_iter.hh | 24 ++++++-
util/internal/graph_iter_base.hh | 1
util/vertex.hh | 88 +++++++++++++++++-----------
19 files changed, 177 insertions(+), 149 deletions(-)
Index: mln/core/site_set/p_vertices.hh
--- mln/core/site_set/p_vertices.hh (revision 2888)
+++ mln/core/site_set/p_vertices.hh (working copy)
@@ -34,13 +34,9 @@
# include <mln/core/internal/site_set_base.hh>
# include <mln/core/site_set/p_graph_piter.hh>
-# include <mln/util/internal/graph_vertex_psite.hh>
+# include <mln/core/site_set/p_vertices_psite.hh>
# include <mln/util/graph.hh>
- //# include <mln/util/tracked_ptr.hh>
-
- //# include <mln/core/image/graph_psite.hh>
- //# include <mln/core/site_set/p_vertices_piter.hh>
namespace mln
@@ -52,6 +48,7 @@
namespace trait
{
+
template <typename G, typename F>
struct site_set_< p_vertices<G, F> >
{
@@ -61,6 +58,7 @@
typedef trait::site_set::contents::fixed contents;
typedef trait::site_set::arity::unique arity;
};
+
} // end of namespace mln::trait
@@ -104,7 +102,7 @@
typedef mln_site(super_) element;
/// Point_Site associated type.
- typedef internal::vertex_psite<G, F> psite;
+ typedef p_vertices_psite<G,F> psite;
/// Forward Site_Iterator associated type.
typedef p_graph_piter< self_, mln_vertex_fwd_iter(G) > fwd_piter;
Index: mln/core/site_set/p_edges.hh
--- mln/core/site_set/p_edges.hh (revision 2888)
+++ mln/core/site_set/p_edges.hh (working copy)
@@ -29,11 +29,12 @@
# define MLN_CORE_SITE_SET_P_EDGES_HH
/// \file mln/core/site_set/p_edges.hh
- /// \brief Definition of a site set based on graph edges.
+///
+/// Definition of a site set based on graph edges.
# include <mln/core/internal/site_set_base.hh>
# include <mln/core/site_set/p_graph_piter.hh>
-# include <mln/util/internal/graph_edge_psite.hh>
+# include <mln/core/site_set/p_edges_psite.hh>
# include <mln/util/graph.hh>
@@ -90,7 +91,7 @@
typedef mln_site(super_) element;
/// Point_Site associated type.
- typedef internal::edge_psite<G, F> psite;
+ typedef p_edges_psite<G, F> psite;
/// Forward Site_Iterator associated type.
typedef p_graph_piter< self_, mln_edge_fwd_iter(G) > fwd_piter;
Index: mln/core/site_set/p_vertices_psite.hh
--- mln/core/site_set/p_vertices_psite.hh (revision 2888)
+++ mln/core/site_set/p_vertices_psite.hh (working copy)
@@ -25,16 +25,16 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef MLN_UTIL_INTERNAL_GRAPH_VERTEX_PSITE_HH
-# define MLN_UTIL_INTERNAL_GRAPH_VERTEX_PSITE_HH
+#ifndef MLN_CORE_SITE_SET_P_VERTICES_PSITE_HH
+# define MLN_CORE_SITE_SET_P_VERTICES_PSITE_HH
-/// \file mln/util/internal/graph_vertex_psite.hh
+/// \file mln/core/site_set/p_vertices_psite.hh
///
/// Implementation of p_vertices psite.
# include <mln/core/concept/pseudo_site.hh>
-# include <mln/util/internal/graph_psite_base.hh>
-# include <mln/util/internal/graph_vertex.hh>
+# include <mln/core/internal/graph_psite_base.hh>
+# include <mln/util/vertex.hh>
namespace mln
@@ -44,23 +44,20 @@
template <typename G, typename F> class p_vertices;
- namespace internal
- {
-
template <typename G, typename F>
- class vertex_psite :
- public graph_psite_base< p_vertices<G,F>,
- vertex_psite<G,F> >
+ class p_vertices_psite :
+
+ public internal::graph_psite_base< p_vertices<G,F>, p_vertices_psite<G,F> >
{
- typedef vertex_psite<G,F> self_;
- typedef graph_psite_base<p_vertices<G,F>, self_> super_;
+ typedef p_vertices_psite<G,F> self_;
+ typedef internal::graph_psite_base<p_vertices<G,F>, self_> super_;
public:
- vertex_psite();
- vertex_psite(const p_vertices<G,F>& s);
- vertex_psite(const p_vertices<G,F>& s, unsigned id);
+ p_vertices_psite();
+ p_vertices_psite(const p_vertices<G,F>& s);
+ p_vertices_psite(const p_vertices<G,F>& s, unsigned id);
const util::vertex<G>& v() const;
};
@@ -71,20 +68,20 @@
template <typename G, typename F>
inline
- vertex_psite<G, F>::vertex_psite()
+ p_vertices_psite<G, F>::p_vertices_psite()
{
}
template <typename G, typename F>
inline
- vertex_psite<G, F>::vertex_psite(const p_vertices<G,F>& s)
+ p_vertices_psite<G, F>::p_vertices_psite(const p_vertices<G,F>& s)
: super_(s)
{
}
template <typename G, typename F>
inline
- vertex_psite<G, F>::vertex_psite(const p_vertices<G,F>& s, unsigned i)
+ p_vertices_psite<G, F>::p_vertices_psite(const p_vertices<G,F>& s, unsigned i)
: super_(s, i)
{
}
@@ -92,17 +89,15 @@
template <typename G, typename F>
inline
const util::vertex<G>&
- vertex_psite<G, F>::v() const
+ p_vertices_psite<G, F>::v() const
{
return this->elt_;
}
# endif // ! MLN_INCLUDE_ONLY
-} // end of namespace internal
-
} // end of namespace mln
-#endif // !MLN_UTIL_INTERNAL_GRAPH_VERTEX_PSITE_HH
+#endif // ! MLN_CORE_SITE_SET_P_VERTICES_PSITE_HH
Property changes on: mln/core/site_set/p_vertices_psite.hh
___________________________________________________________________
Added: svn:mergeinfo
Index: mln/core/site_set/p_edges_psite.hh
--- mln/core/site_set/p_edges_psite.hh (revision 2888)
+++ mln/core/site_set/p_edges_psite.hh (working copy)
@@ -25,15 +25,15 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef MLN_UTIL_INTERNAL_GRAPH_EDGE_PSITE_HH
-# define MLN_UTIL_INTERNAL_GRAPH_EDGE_PSITE_HH
+#ifndef MLN_CORE_SITE_SET_P_EDGES_PSITE_HH
+# define MLN_CORE_SITE_SET_P_EDGES_PSITE_HH
-/// \file mln/util/internal/graph_edge_psite.hh
+/// \file mln/core/site_set/p_edges_psite.hh
///
/// Implementation of p_edges psite.
-# include <mln/util/internal/graph_psite_base.hh>
-# include <mln/util/internal/graph_edge.hh>
+# include <mln/core/internal/graph_psite_base.hh>
+# include <mln/util/edge.hh>
namespace mln
@@ -43,25 +43,20 @@
template <typename G, typename F> class p_edges;
- namespace internal
- {
-
-
template <typename G, typename F>
- class edge_psite :
- public graph_psite_base< p_edges<G,F>,
- edge_psite<G,F> >
+ class p_edges_psite :
+ public internal::graph_psite_base< p_edges<G,F>, p_edges_psite<G,F> >
{
- typedef edge_psite<G,F> self_;
- typedef graph_psite_base<p_edges<G,F>, self_> super_;
+ typedef p_edges_psite<G,F> self_;
+ typedef internal::graph_psite_base<p_edges<G,F>, self_> super_;
public:
/// Constructors
/// \{
- edge_psite();
- edge_psite(const p_edges<G,F>& s);
- edge_psite(const p_edges<G,F>& s, unsigned);
+ p_edges_psite();
+ p_edges_psite(const p_edges<G,F>& s);
+ p_edges_psite(const p_edges<G,F>& s, unsigned);
/// \}
/// Accessors
@@ -78,20 +73,20 @@
template <typename G, typename F>
inline
- edge_psite<G, F>::edge_psite()
+ p_edges_psite<G, F>::p_edges_psite()
{
}
template <typename G, typename F>
inline
- edge_psite<G, F>::edge_psite(const p_edges<G,F>& s)
+ p_edges_psite<G, F>::p_edges_psite(const p_edges<G,F>& s)
: super_(s)
{
}
template <typename G, typename F>
inline
- edge_psite<G, F>::edge_psite(const p_edges<G,F>& s, unsigned id)
+ p_edges_psite<G, F>::p_edges_psite(const p_edges<G,F>& s, unsigned id)
: super_(s, id)
{
}
@@ -99,17 +94,15 @@
template <typename G, typename F>
inline
const util::edge<G>&
- edge_psite<G, F>::e() const
+ p_edges_psite<G, F>::e() const
{
return this->elt_;
}
# endif // ! MLN_INCLUDE_ONLY
-} // end of namespace internal
-
} // end of namespace mln
-#endif // ! MLN_UTIL_INTERNAL_GRAPH_EDGE_PSITE_HH
+#endif // ! MLN_CORE_SITE_SET_P_EDGES_PSITE_HH
Property changes on: mln/core/site_set/p_edges_psite.hh
___________________________________________________________________
Added: svn:mergeinfo
Index: mln/core/image/line_graph_neighborhood_piter.hh
--- mln/core/image/line_graph_neighborhood_piter.hh (revision 2888)
+++ mln/core/image/line_graph_neighborhood_piter.hh (working copy)
@@ -194,7 +194,7 @@
mln_psite(N)
line_graph_neighborhood_fwd_piter<G, F, N>::compute_p_() const
{
- return internal::edge_psite<G, F>(this->center().site_set(), *i_);
+ return p_edges_psite<G, F>(this->center().site_set(), *i_);
}
@@ -256,7 +256,7 @@
mln_psite(N)
line_graph_neighborhood_bkd_piter<G, F, N>::compute_p_() const
{
- return internal::edge_psite<G, F>(this->center().site_set(), *i_);
+ return p_edges_psite<G, F>(this->center().site_set(), *i_);
}
# endif // ! MLN_INCLUDE_ONLY
Index: mln/core/image/line_graph_window_piter.hh
--- mln/core/image/line_graph_window_piter.hh (revision 2888)
+++ mln/core/image/line_graph_window_piter.hh (working copy)
@@ -193,7 +193,7 @@
mln_psite(W)
line_graph_window_fwd_piter<G, F, W>::compute_p_() const
{
- return internal::edge_psite<G, F>(this->center().site_set(), *i_);
+ return p_edges_psite<G, F>(this->center().site_set(), *i_);
}
@@ -255,7 +255,7 @@
mln_psite(W)
line_graph_window_bkd_piter<G, F, W>::compute_p_() const
{
- return internal::edge_psite<G, F>(this->center().site_set(), *i_);
+ return p_edges_psite<G, F>(this->center().site_set(), *i_);
}
# endif // ! MLN_INCLUDE_ONLY
Index: mln/core/image/line_graph_elt_window.hh
--- mln/core/image/line_graph_elt_window.hh (revision 2888)
+++ mln/core/image/line_graph_elt_window.hh (working copy)
@@ -30,11 +30,12 @@
# define MLN_CORE_IMAGE_LINE_GRAPH_ELT_WINDOW_HH
/// \file mln/core/image/line_graph_elt_window.hh
+///
/// Definition of the elementary ``window'' on a line graph.
# include <mln/core/concept/window.hh>
# include <mln/core/internal/graph_window_base.hh>
-# include <mln/util/internal/graph_edge_psite.hh>
+# include <mln/core/site_set/p_edges_psite.hh>
# include <mln/core/image/line_graph_window_piter.hh>
@@ -64,7 +65,7 @@
class line_graph_elt_window : public graph_window_base<
G,
F,
- internal::edge_psite<G, F>,
+ p_edges_psite<G, F>,
line_graph_elt_window<G, F> >
{
typedef line_graph_elt_window<G, F> self_;
@@ -73,7 +74,7 @@
/// Associated types.
/// \{
/// The type of psite corresponding to the window.
- typedef internal::edge_psite<G, F> psite;
+ typedef p_edges_psite<G, F> psite;
/// Site_Iterator type to browse the psites of the window
/// w.r.t. the ordering of edges.
Index: mln/core/image/line_graph_elt_neighborhood.hh
--- mln/core/image/line_graph_elt_neighborhood.hh (revision 2888)
+++ mln/core/image/line_graph_elt_neighborhood.hh (working copy)
@@ -30,13 +30,14 @@
# define MLN_CORE_IMAGE_LINE_GRAPH_ELT_NEIGHBORHOOD_HH
/// \file mln/core/image/line_graph_elt_neighborhood.hh
+///
/// Definition of the elementary ``neighborhood'' on a line graph.
# include <set>
# include <mln/core/concept/neighborhood.hh>
# include <mln/core/internal/graph_neighborhood_base.hh>
-# include <mln/util/internal/graph_edge_psite.hh>
+# include <mln/core/site_set/p_edges_psite.hh>
# include <mln/core/image/line_graph_neighborhood_piter.hh>
# include <mln/core/image/line_graph_elt_window.hh>
@@ -50,7 +51,7 @@
class line_graph_elt_neighborhood
: public graph_neighborhood_base<G,
F,
- internal::edge_psite<G, F>,
+ p_edges_psite<G, F>,
line_graph_elt_neighborhood<G, F> >
{
typedef line_graph_elt_neighborhood<G, F> self_;
@@ -59,7 +60,7 @@
/// Associated types.
/// \{
/// The type of psite corresponding to the neighborhood.
- typedef internal::edge_psite<G, F> psite;
+ typedef p_edges_psite<G, F> psite;
/// Site_Iterator type to browse the psites of the
/// neighborhood w.r.t. the ordering of edges.
Index: mln/core/image/graph_window_piter.hh
--- mln/core/image/graph_window_piter.hh (revision 2888)
+++ mln/core/image/graph_window_piter.hh (working copy)
@@ -190,7 +190,7 @@
mln_psite(W)
graph_window_fwd_piter<G, F, W>::compute_p_() const
{
- return internal::vertex_psite<G, F>(this->center().site_set(), *i_);
+ return p_vertices_psite<G, F>(this->center().site_set(), *i_);
}
@@ -252,7 +252,7 @@
mln_psite(W)
graph_window_bkd_piter<G, F, W>::compute_p_() const
{
- return internal::vertex_psite<G, F>(this->center().site_set(), *i_);
+ return p_vertices_psite<G, F>(this->center().site_set(), *i_);
}
# endif // ! MLN_INCLUDE_ONLY
Index: mln/core/image/graph_neighborhood_piter.hh
--- mln/core/image/graph_neighborhood_piter.hh (revision 2888)
+++ mln/core/image/graph_neighborhood_piter.hh (working copy)
@@ -194,7 +194,7 @@
mln_psite(N)
graph_neighborhood_fwd_piter<G, F, N>::compute_p_() const
{
- return internal::vertex_psite<G, F>(this->center().site_set(), *i_);
+ return p_vertices_psite<G, F>(this->center().site_set(), *i_);
}
@@ -256,7 +256,7 @@
mln_psite(N)
graph_neighborhood_bkd_piter<G, F, N>::compute_p_() const
{
- return internal::vertex_psite<G, F>(this->center().site_set(), *i_);
+ return p_vertices_psite<G, F>(this->center().site_set(), *i_);
}
Index: mln/core/image/graph_elt_neighborhood.hh
--- mln/core/image/graph_elt_neighborhood.hh (revision 2888)
+++ mln/core/image/graph_elt_neighborhood.hh (working copy)
@@ -36,7 +36,7 @@
# include <mln/core/concept/neighborhood.hh>
# include <mln/core/internal/graph_neighborhood_base.hh>
-# include <mln/util/internal/graph_vertex_psite.hh>
+# include <mln/core/site_set/p_vertices_psite.hh>
# include <mln/core/image/graph_neighborhood_piter.hh>
# include <mln/core/image/graph_elt_window.hh>
@@ -54,7 +54,7 @@
class graph_elt_neighborhood
: public graph_neighborhood_base<G,
F,
- internal::vertex_psite<G, F>,
+ p_vertices_psite<G, F>,
graph_elt_neighborhood<G, F> >
{
typedef graph_elt_neighborhood<G, F> self_;
@@ -63,7 +63,7 @@
/// Associated types.
/// \{
/// The type of psite corresponding to the neighborhood.
- typedef internal::vertex_psite<G, F> psite;
+ typedef p_vertices_psite<G, F> psite;
/// Site_Iterator type to browse the psites of the
/// neighborhood w.r.t. the ordering of vertices.
Index: mln/core/image/graph_elt_window.hh
--- mln/core/image/graph_elt_window.hh (revision 2888)
+++ mln/core/image/graph_elt_window.hh (working copy)
@@ -34,7 +34,7 @@
# include <mln/core/concept/window.hh>
# include <mln/core/internal/graph_window_base.hh>
-# include <mln/util/internal/graph_vertex_psite.hh>
+# include <mln/core/site_set/p_vertices_psite.hh>
# include <mln/core/image/graph_window_piter.hh>
@@ -64,7 +64,7 @@
class graph_elt_window : public graph_window_base<
G,
F,
- internal::vertex_psite<G, F>,
+ p_vertices_psite<G, F>,
graph_elt_window<G, F> >
{
@@ -74,7 +74,7 @@
/// Associated types.
/// \{
/// The type of psite corresponding to the window.
- typedef internal::vertex_psite<G, F> psite;
+ typedef p_vertices_psite<G, F> psite;
/// \brief Site_Iterator type to browse the psites of the window
/// w.r.t. the ordering of vertices.
Index: mln/core/internal/graph_psite_base.hh
--- mln/core/internal/graph_psite_base.hh (revision 2888)
+++ mln/core/internal/graph_psite_base.hh (working copy)
@@ -25,10 +25,10 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef MLN_UTIL_INTERNAL_GRAPH_PSITE_BASE_HH
-# define MLN_UTIL_INTERNAL_GRAPH_PSITE_BASE_HH
+#ifndef MLN_CORE_INTERNAL_GRAPH_PSITE_BASE_HH
+# define MLN_CORE_INTERNAL_GRAPH_PSITE_BASE_HH
-/// \file mln/util/internal/graph_psite_base.hh
+/// \file mln/core/internal/graph_psite_base.hh
///
/// Base implementation for graph based psites.
@@ -113,11 +113,11 @@
};
- /// Comparison of two mln::graph_psite_base<S,E> instances.
- /// \{
/* FIXME: Shouldn't those comparisons be part of a much general
mechanism? */
+ /// Comparison of two mln::graph_psite_base<S,E> instances.
+ /// \{
/// \brief Is \a lhs equal to \a rhs?
///
/// \pre Arguments \a lhs and \a rhs must belong to the same
@@ -145,19 +145,10 @@
operator< (const graph_psite_base<S,E>& lhs, const graph_psite_base<S,E>& rhs);
/// \}
-} // end of namespace internal
-
- } // end of namespace mln
-
# ifndef MLN_INCLUDE_ONLY
-namespace mln
-{
-
- namespace internal
- {
template <typename S, typename E>
inline
@@ -295,11 +286,12 @@
return lhs.id() < rhs.id();
}
+# endif // ! MLN_INCLUDE_ONLY
+
} // end of namespace internal
} // end of namespace mln
-# endif // !MLN_INCLUDE_ONLY
-#endif // !MLN_UTIL_INTERNAL_GRAPH_PSITE_BASE_HH
+#endif // ! MLN_CORE_INTERNAL_GRAPH_PSITE_BASE_HH
Property changes on: mln/core/internal/graph_psite_base.hh
___________________________________________________________________
Added: svn:mergeinfo
Index: mln/util/all.hh
--- mln/util/all.hh (revision 2888)
+++ mln/util/all.hh (working copy)
@@ -1,4 +1,5 @@
// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory
+// (LRDE)
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -28,10 +29,9 @@
#ifndef MLN_UTIL_ALL_HH
# define MLN_UTIL_ALL_HH
-/*! \file mln/util/all.hh
- *
- * \brief File that includes all util-related routines.
- */
+/// \file mln/util/all.hh
+///
+/// File that includes all util-related routines.
namespace mln
@@ -52,6 +52,7 @@
# include <mln/util/branch_iter_ind.hh>
# include <mln/util/dindex.hh>
# include <mln/util/eat.hh>
+# include <mln/util/edge.hh>
# include <mln/util/graph.hh>
# include <mln/util/greater_point.hh>
# include <mln/util/greater_psite.hh>
@@ -73,6 +74,7 @@
# include <mln/util/tree_fast_to_image.hh>
# include <mln/util/tree_to_fast.hh>
//# include <mln/util/tree_to_image.hh>
+# include <mln/util/vertex.hh>
# include <mln/util/yes.hh>
#endif // ! MLN_UTIL_ALL_HH
Index: mln/util/internal/graph_iter.hh
--- mln/util/internal/graph_iter.hh (revision 2888)
+++ mln/util/internal/graph_iter.hh (working copy)
@@ -28,13 +28,15 @@
#ifndef MLN_UTIL_INTERNAL_GRAPH_ITER_HH
# define MLN_UTIL_INTERNAL_GRAPH_ITER_HH
-# include <mln/core/concept/iterator.hh>
-# include <mln/util/internal/graph_vertex.hh>
-# include <mln/util/internal/graph_edge.hh>
+/// \file mln/util/internal/graph_iter.hh
+///
+/// Implementation for graph iterators.
+
# include <mln/util/internal/graph_iter_base.hh>
+# include <mln/util/vertex.hh>
+# include <mln/util/edge.hh>
+
-/// \file mln/util/internal/graph_iter.hh
-/// \brief Implementation for graph iterators.
namespace mln
{
@@ -42,6 +44,8 @@
namespace internal
{
+ /// Forward vertex iterator.
+
template<typename G>
class vertex_fwd_iterator
: public graph_iter_base<G, util::vertex<G>, vertex_fwd_iterator<G> >
@@ -69,6 +73,8 @@
};
+ /// Backward vertex iterator.
+
template<typename G>
class vertex_bkd_iterator
: public graph_iter_base<G, util::vertex<G>, vertex_bkd_iterator<G> >
@@ -95,7 +101,9 @@
friend class graph_iter_base<G, util::vertex<G>, vertex_bkd_iterator<G> >;
};
+
/// Forward edge iterator.
+
template <typename G>
class edge_fwd_iterator
: public graph_iter_base<G, util::edge<G>, edge_fwd_iterator<G> >
@@ -122,6 +130,9 @@
friend class graph_iter_base<G, util::edge<G>, edge_fwd_iterator<G> >;
};
+
+ /// Backward edge iterator.
+
template <typename G>
class edge_bkd_iterator
: public graph_iter_base<G, util::edge<G>, edge_bkd_iterator<G> >
@@ -150,8 +161,10 @@
+
# ifndef MLN_INCLUDE_ONLY
+
/*--------------------`
| vertex_fwd_iterator |
\--------------------*/
@@ -296,5 +309,6 @@
} // end of namespace mln
+
#endif // ! MLN_UTIL_INTERNAL_GRAPH_ITER_HH
Index: mln/util/internal/graph_base.hh
--- mln/util/internal/graph_base.hh (revision 2888)
+++ mln/util/internal/graph_base.hh (working copy)
@@ -30,12 +30,11 @@
# define MLN_UTIL_INTERNAL_GRAPH_BASE_HH
/// \file mln/util/internal/graph_base.hh
-/// \brief Factored implementation of undirected graphs.
+///
+/// Factored implementation of undirected graphs.
# include <cstddef>
-
# include <algorithm>
-
# include <vector>
# include <set>
# include <ostream>
@@ -45,8 +44,8 @@
# include <mln/core/concept/proxy.hh>
# include <mln/core/internal/data.hh>
-# include <mln/util/internal/graph_edge.hh>
-# include <mln/util/internal/graph_vertex.hh>
+# include <mln/util/edge.hh>
+# include <mln/util/vertex.hh>
# include <mln/util/ord_pair.hh>
# include <mln/util/tracked_ptr.hh>
Index: mln/util/internal/graph_iter_base.hh
--- mln/util/internal/graph_iter_base.hh (revision 2888)
+++ mln/util/internal/graph_iter_base.hh (working copy)
@@ -37,7 +37,6 @@
# include <mln/core/concept/iterator.hh>
# include <mln/core/concept/proxy.hh>
-# include <mln/util/internal/graph_edge.hh>
namespace mln
Index: mln/util/edge.hh
--- mln/util/edge.hh (revision 2888)
+++ mln/util/edge.hh (working copy)
@@ -25,10 +25,10 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef MLN_UTIL_INTERNAL_GRAPH_EDGE_HH
-# define MLN_UTIL_INTERNAL_GRAPH_EDGE_HH
+#ifndef MLN_UTIL_EDGE_HH
+# define MLN_UTIL_EDGE_HH
-/// \file mln/util/internal/graph_edge.hh
+/// \file mln/util/edge.hh
///
/// Definition of a graph edge.
@@ -110,6 +110,7 @@
unsigned id_;
};
+
template <typename G>
std::ostream&
operator<<(std::ostream& ostr, const edge<G>& p);
@@ -122,14 +123,16 @@
bool
operator< (const edge<G>& lhs, const edge<G>& rhs);
- } // End of namespace mln::util
+ } // end of namespace mln::util
+
- /// subject_impl specialization (Proxy)
- /// \{
namespace internal
{
+ /// subject_impl specialization (Proxy)
+ /// \{
+
template <typename G, typename E>
struct subject_impl< const util::edge<G>, E >
{
@@ -159,9 +162,11 @@
E& exact_();
};
- } // end of namespace mln::internal
/// \}
+ } // end of namespace mln::internal
+
+
# ifndef MLN_INCLUDE_ONLY
@@ -290,6 +295,7 @@
}
template <typename G>
+ inline
std::ostream&
operator<<(std::ostream& ostr, const edge<G>& p)
{
@@ -314,6 +320,8 @@
} // end of namespace mln::util
+
+
namespace internal
{
@@ -422,11 +430,12 @@
return exact_().get_subject().invalidate();
}
- } // End of namespace mln::internal
+ } // end of namespace mln::internal
# endif // !MLN_INCLUDE_ONLY
-} // End of namespace mln
+} // end of namespace mln
+
-#endif // !MLN_UTIL_INTERNAL_GRAPH_EDGE_HH
+#endif // ! MLN_UTIL_EDGE_HH
Property changes on: mln/util/edge.hh
___________________________________________________________________
Added: svn:mergeinfo
Index: mln/util/vertex.hh
--- mln/util/vertex.hh (revision 2888)
+++ mln/util/vertex.hh (working copy)
@@ -25,12 +25,12 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef MLN_UTIL_INTERNAL_GRAPH_VERTEX_HH
-# define MLN_UTIL_INTERNAL_GRAPH_VERTEX_HH
+#ifndef MLN_UTIL_VERTEX_HH
+# define MLN_UTIL_VERTEX_HH
# include <mln/util/internal/graph_vertex_impl.hh>
-/// \file mln/util/internal/graph_vertex.hh
+/// \file mln/util/vertex.hh
///
/// Implementation of a graph vertex.
@@ -43,6 +43,7 @@
{
/// Vertex of a graph \p G.
+
template<typename G>
class vertex : public internal::vertex_impl_<G>
{
@@ -96,23 +97,35 @@
unsigned id_;
};
- /// Comparison operator. Test whether two vertices have the same id.
+
+ /// Push the vertex \p v in the output stream \p ostr.
+ template <typename G>
+ std::ostream&
+ operator<<(std::ostream& ostr, const vertex<G>& v);
+
+ /// Equality operator. Test whether two vertices have the same
+ /// id.
template<typename G>
bool
- operator==(const util::vertex<G>& v1, const util::vertex<G>& v2);
+ operator==(const vertex<G>& v1, const vertex<G>& v2);
- /// Inferior operator. Test whether lhs.id() < rhs.id().
+
+ /// Less operator. Test whether lhs.id() < rhs.id().
template<typename G>
bool
- operator<(const util::vertex<G>& lhs, const util::vertex<G>& rhs);
+ operator<(const vertex<G>& lhs, const vertex<G>& rhs);
+
+
+ } // end of namespace mln::util
- } // End of namespace mln::util
-/// subject_impl specialization (Proxy)
-/// \{
namespace internal
{
+
+ /// \{
+ /// subject_impl specialization (Proxy)
+
template <typename G, typename E>
struct subject_impl< const util::vertex<G>, E >
{
@@ -142,10 +155,13 @@
E& exact_();
};
+ /// \}
+
} // end of namespace mln::internal
-} // End of namespace mln
-/// \}
+} // end of namespace mln
+
+
# ifndef MLN_INCLUDE_ONLY
@@ -158,24 +174,6 @@
template<typename G>
inline
- bool
- operator==(const util::vertex<G>& v1, const util::vertex<G>& v2)
- {
- return v1.id() == v2.id();
- }
-
- template<typename G>
- inline
- bool
- operator<(const util::vertex<G>& lhs, const util::vertex<G>& rhs)
- {
- return lhs.id() < rhs.id();
- }
-
-
-
- template <typename G>
- inline
vertex<G>::vertex()
{
invalidate();
@@ -293,8 +291,34 @@
return id_;
}
+
+ template <typename G>
+ inline
+ std::ostream&
+ operator<<(std::ostream& ostr, const vertex<G>& v)
+ {
+ return ostr << v.id();
+ }
+
+ template<typename G>
+ inline
+ bool
+ operator==(const vertex<G>& v1, const vertex<G>& v2)
+ {
+ return v1.id() == v2.id();
+ }
+
+ template<typename G>
+ inline
+ bool
+ operator<(const vertex<G>& lhs, const vertex<G>& rhs)
+ {
+ return lhs.id() < rhs.id();
+ }
+
} // end of namespace mln::util
+
namespace internal
{
@@ -406,10 +430,10 @@
} // end of namespace mln::internal
-} // End of namespace mln
+} // end of namespace mln
# endif // !MLN_INCLUDE_ONLY
-#endif // !MLN_UTIL_INTERNAL_GRAPH_VERTEX_HH
+#endif // ! MLN_UTIL_VERTEX_HH
Property changes on: mln/util/vertex.hh
___________________________________________________________________
Added: svn:mergeinfo
1
0
https://svn.lrde.epita.fr/svn/oln/branches/cleanup-2008/milena
Index: ChangeLog
from Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
Some fixes in graph-related materials.
* tests/core/site_set/p_vertices.cc: Layout.
(UINT_MAX): Fix warning; use mln_max(unsigned).
* tests/core/site_set/p_edges.cc: Likewise.
* mln/core/site_set/p_vertices.hh (graph_t): (Re-)New.
* mln/core/site_set/p_edges.hh: .
It is used so it is featured!
* mln/algebra/vec.hh: Upgrade doc style.
(operator/): Fix warning with g++-4.3.
* mln/util/internal/graph_edge.hh (graph): Fix return sig.
* mln/util/internal/graph_vertex.hh: Likewise.
* mln/util/internal/graph_edge_psite.hh: Layout.
(e): Fix missing update; inherited attr is elt_.
* mln/util/internal/graph_vertex_psite.hh: Likewise.
* mln/util/internal/graph_psite_base.hh: Layout.
(super): Remove; unused.
Layout.
mln/algebra/vec.hh | 11 +++++------
mln/core/site_set/p_edges.hh | 5 +++++
mln/core/site_set/p_vertices.hh | 4 ++++
mln/util/internal/graph_edge.hh | 6 +++---
mln/util/internal/graph_edge_psite.hh | 15 +++------------
mln/util/internal/graph_psite_base.hh | 12 ++++--------
mln/util/internal/graph_vertex.hh | 6 +++---
mln/util/internal/graph_vertex_psite.hh | 18 ++++--------------
tests/core/site_set/p_edges.cc | 11 +++++++----
tests/core/site_set/p_vertices.cc | 7 +++++--
10 files changed, 43 insertions(+), 52 deletions(-)
Index: tests/core/site_set/p_vertices.cc
--- tests/core/site_set/p_vertices.cc (revision 2887)
+++ tests/core/site_set/p_vertices.cc (working copy)
@@ -34,6 +34,7 @@
#include <mln/core/site_set/p_vertices.hh>
#include <mln/fun/i2v/array.hh>
+
int main()
{
using namespace mln;
@@ -63,6 +64,7 @@
typedef p_vertices<util::graph, F> p_vertices;
p_vertices pv(g, f);
+ // Forward iterator.
{
mln_fwd_piter_(p_vertices) p(pv);
unsigned i = 0;
@@ -70,13 +72,14 @@
mln_assertion(p.p_hook_().v().id() == i++);
mln_assertion(i == g.v_nmax());
}
+
+ // Backward iterator.
{
mln_bkd_piter_(p_vertices) p(pv);
unsigned i = g.v_nmax() - 1;
for_all(p)
mln_assertion(p.p_hook_().v().id() == i--);
- mln_assertion(i == UINT_MAX);
+ mln_assertion(i == mln_max(unsigned));
}
- return 0;
}
Index: tests/core/site_set/p_edges.cc
--- tests/core/site_set/p_edges.cc (revision 2887)
+++ tests/core/site_set/p_edges.cc (working copy)
@@ -34,7 +34,9 @@
#include <mln/core/alias/point2d.hh>
#include <mln/core/site_set/p_edges.hh>
+
// Function mapping an edge to a specific site.
+
template <typename G>
struct my_fun
{
@@ -48,6 +50,7 @@
}
};
+
int main()
{
using namespace mln;
@@ -72,7 +75,7 @@
typedef p_edges<util::graph, my_fun<util::graph> > p_edges;
p_edges pv(g, my_fun<util::graph>());
- // Forward iterator
+ // Forward iterator.
{
mln_fwd_piter_(p_edges) p(pv);
unsigned i = 0;
@@ -80,14 +83,14 @@
mln_assertion(p.p_hook_().e().id() == i++);
mln_assertion(i == g.e_nmax());
}
- // Backward iterator
+
+ // Backward iterator.
{
mln_bkd_piter_(p_edges) p(pv);
unsigned i = g.e_nmax() - 1;
for_all(p)
mln_assertion(p.p_hook_().e().id() == i--);
- mln_assertion(i == UINT_MAX);
+ mln_assertion(i == mln_max(unsigned));
}
- return 0;
}
Index: mln/core/site_set/p_vertices.hh
--- mln/core/site_set/p_vertices.hh (revision 2887)
+++ mln/core/site_set/p_vertices.hh (working copy)
@@ -75,6 +75,10 @@
public:
+ /// Graph associated type.
+ typedef G graph_t;
+
+
/// Type of graph vertex.
typedef util::vertex<G> vertex;
Index: mln/core/site_set/p_edges.hh
--- mln/core/site_set/p_edges.hh (revision 2887)
+++ mln/core/site_set/p_edges.hh (working copy)
@@ -39,9 +39,11 @@
namespace mln
{
+
// Forward declaration.
template <typename G, typename F> struct p_edges;
+
namespace trait
{
template <typename G, typename F>
@@ -66,6 +68,9 @@
public:
+ /// Graph associated type.
+ typedef G graph_t;
+
/// Type of graph edge.
typedef util::edge<G> edge;
Index: mln/algebra/vec.hh
--- mln/algebra/vec.hh (revision 2887)
+++ mln/algebra/vec.hh (working copy)
@@ -1,4 +1,5 @@
// Copyright (C) 2006, 2008 EPITA Research and Development Laboratory
+// (LRDE)
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -28,11 +29,9 @@
#ifndef MLN_ALGEBRA_VEC_HH
# define MLN_ALGEBRA_VEC_HH
-/*!
- * \file mln/algebra/vec.hh
- *
- * \brief Definition of a generic vector class.
- */
+/// \file mln/algebra/vec.hh
+///
+/// Definition of a generic vector class.
# include <iostream>
# include <cmath>
@@ -533,7 +532,7 @@
vec<n, mln_trait_op_div(T, S)>
operator/(const vec<n,T>& lhs, const mln::value::scalar_<S>& s)
{
- mln_precondition(value::equiv(s) != literal::zero);
+ mln_precondition(value::equiv(s) != (S)(literal::zero));
vec<n, mln_trait_op_div(T, S)> tmp;
for (unsigned i = 0; i < n; ++i)
tmp[i] = lhs[i] / s.to_equiv();
Index: mln/util/internal/graph_edge.hh
--- mln/util/internal/graph_edge.hh (revision 2887)
+++ mln/util/internal/graph_edge.hh (working copy)
@@ -134,7 +134,7 @@
struct subject_impl< const util::edge<G>, E >
{
unsigned id() const;
- const mlc_const(G)& graph() const;
+ const G& graph() const;
unsigned v_other(unsigned id_v) const;
bool is_valid() const;
unsigned v1() const;
@@ -213,7 +213,7 @@
template <typename G>
inline
- const typename edge<G>::G&
+ const G&
edge<G>::graph() const
{
return g_;
@@ -339,7 +339,7 @@
template <typename G, typename E>
inline
- const mlc_const(G)&
+ const G&
subject_impl< const util::edge<G>, E >::graph() const
{
return exact_().get_subject().graph();
Index: mln/util/internal/graph_edge_psite.hh
--- mln/util/internal/graph_edge_psite.hh (revision 2887)
+++ mln/util/internal/graph_edge_psite.hh (working copy)
@@ -72,20 +72,10 @@
};
- } // end of namespace mln::internal
-
-} // end of namespace mln
-
# ifndef MLN_INCLUDE_ONLY
-namespace mln
-{
-
- namespace internal
- {
-
template <typename G, typename F>
inline
edge_psite<G, F>::edge_psite()
@@ -111,14 +101,15 @@
const util::edge<G>&
edge_psite<G, F>::e() const
{
- return this->v_;
+ return this->elt_;
}
+# endif // ! MLN_INCLUDE_ONLY
+
} // end of namespace internal
} // end of namespace mln
-# endif // !MLN_INCLUDE_ONLY
#endif // !MLN_UTIL_INTERNAL_GRAPH_EDGE_PSITE_HH
Index: mln/util/internal/graph_vertex.hh
--- mln/util/internal/graph_vertex.hh (revision 2887)
+++ mln/util/internal/graph_vertex.hh (working copy)
@@ -117,7 +117,7 @@
struct subject_impl< const util::vertex<G>, E >
{
bool is_valid() const;
- const mlc_const(G)& graph() const;
+ const G& graph() const;
unsigned id() const;
unsigned other(unsigned id_e) const;
@@ -279,7 +279,7 @@
template<typename G>
inline
- const typename vertex<G>::G&
+ const G&
vertex<G>::graph() const
{
return g_;
@@ -316,7 +316,7 @@
template <typename G, typename E>
inline
- const mlc_const(G)&
+ const G&
subject_impl< const util::vertex<G>, E >::graph() const
{
return exact_().get_subject().graph();
Index: mln/util/internal/graph_psite_base.hh
--- mln/util/internal/graph_psite_base.hh (revision 2887)
+++ mln/util/internal/graph_psite_base.hh (working copy)
@@ -32,18 +32,16 @@
///
/// Base implementation for graph based psites.
-# include <mln/core/concept/pseudo_site.hh>
+# include <mln/core/internal/pseudo_site_base.hh>
+
+
namespace mln
{
+ // Forward declaration.
template <typename G, typename F> class p_vertices;
-} // end of namespace mln
-
-
-namespace mln
-{
namespace internal
{
@@ -52,8 +50,6 @@
class graph_psite_base : public internal::pseudo_site_base_< const mln_site(S)&,
E >
{
- typedef Pseudo_Site< graph_psite_base<S,E> > super;
-
public:
// This associated type is important to know that this particular
Index: mln/util/internal/graph_vertex_psite.hh
--- mln/util/internal/graph_vertex_psite.hh (revision 2887)
+++ mln/util/internal/graph_vertex_psite.hh (working copy)
@@ -66,21 +66,9 @@
};
- } // end of namespace mln::internal
-
-} // end of namespace mln
-
-
-
# ifndef MLN_INCLUDE_ONLY
-namespace mln
-{
-
- namespace internal
- {
-
template <typename G, typename F>
inline
vertex_psite<G, F>::vertex_psite()
@@ -106,13 +94,15 @@
const util::vertex<G>&
vertex_psite<G, F>::v() const
{
- return this->v_;
+ return this->elt_;
}
+# endif // ! MLN_INCLUDE_ONLY
+
} // end of namespace internal
} // end of namespace mln
-# endif // !MLN_INCLUDE_ONLY
+
#endif // !MLN_UTIL_INTERNAL_GRAPH_VERTEX_PSITE_HH
1
0