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
- 9625 discussions
https://svn.lrde.epita.fr/svn/oln/trunk/milena
Index: ChangeLog
from Roland Levillain <roland(a)lrde.epita.fr>
Fix the graph pretty-printer.
* mln/util/internal/graph_base.hh
(mln::util::internal::graph_base<V, E>::print_debug): Print the
adjacent vertices, not the adjacent edges.
graph_base.hh | 15 ++++++++-------
1 file changed, 8 insertions(+), 7 deletions(-)
Index: mln/util/internal/graph_base.hh
--- mln/util/internal/graph_base.hh (revision 2017)
+++ mln/util/internal/graph_base.hh (working copy)
@@ -626,17 +626,18 @@
graph_base<V, E>::print_debug (std::ostream& ostr) const
{
ostr << "graph: " << std::endl;
- int i = 0;
- for (typename vertices_t::const_iterator v = vertices_.begin ();
- v != vertices_.end (); ++v, ++i)
+ for (unsigned v = 0; v < vertices_.size(); ++v)
{
- ostr << "vertex: " << i << std::endl << " -- adjacent vertices: ";
+ ostr << "vertex: " << v << std::endl << " -- adjacent vertices: ";
/* FIXME: We shouldn't manipulate std::vector<edge_id>
directly, but use a typedef instead. */
for (typename std::vector<util::edge_id>::const_iterator e =
- (*v)->edges.begin();
- e != (*v)->edges.end(); ++e)
- ostr << *e << " ";
+ vertices_[v]->edges.begin(); e != vertices_[v]->edges.end();
+ ++e)
+ if (v == edges_[*e]->v1())
+ ostr << edges_[*e]->v2() << " ";
+ else
+ ostr << edges_[*e]->v1() << " ";
ostr << std::endl;
}
ostr << std::endl;
1
0
https://svn.lrde.epita.fr/svn/oln/trunk/milena
This bug has probably been there for weeks... (Since the introduction of
graph_base<V, E>::edges_set_, to be specific.)
Index: ChangeLog
from Roland Levillain <roland(a)lrde.epita.fr>
Fix the insertion of edges into a graph.
* mln/util/internal/graph_base.hh
(mln::util::internal::less_ptr<T>): New functor.
Use it...
(mln::util::internal::graph_base<V, E>::edges_set_t): ...here, to
fix the comparison of edges, and have the search for an existing
edge in graph_base<V, E>::add_edge_ work.
graph_base.hh | 18 +++++++++++++++++-
1 file changed, 17 insertions(+), 1 deletion(-)
Index: mln/util/internal/graph_base.hh
--- mln/util/internal/graph_base.hh (revision 2016)
+++ mln/util/internal/graph_base.hh (working copy)
@@ -196,6 +196,21 @@
namespace internal
{
+ // FIXME: This should be no longer useful once vertices and edges
+ // are handled without pointers and dynamic allocation.
+ template <typename T>
+ struct less_ptr
+ {
+ bool
+ operator()(const T& a, const T& b)
+ {
+ mln_assertion(a);
+ mln_assertion(b);
+ return (*a < *b);
+ }
+ };
+
+
/// \brief Base class for undirected graphs.
template<typename V, typename E>
class graph_base
@@ -211,7 +226,8 @@
/// The type of the set of edges.
typedef std::vector< util::edge<E>* > edges_t;
/// A set to test the presence of a given edge.
- typedef std::set< util::edge<E>* > edges_set_t;
+ typedef std::set< util::edge<E>*,
+ less_ptr< util::edge<E>* > > edges_set_t;
/// Construction, assignments and destruction.
/// \{
1
0
13 Jun '08
https://svn.lrde.epita.fr/svn/oln/branches/cleanup-2008/milena
Index: ChangeLog
from Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
Make windows work with index; test on p_array.
* doc/tutorial/examples/p_array.2.cc: New.
* mln/core/p_array.hh (has): New overload for index.
(operator[]): Likewise.
* mln/core/concept/proxy.hh (get_adr): New overload to handle
identity.
* mln/core/concept/pseudo_site.hh (change_target): Upgrade.
Now it can handle non-Objects.
* mln/core/concept/site_proxy.hh: Likewise.
* mln/util/index.hh: New.
doc/tutorial/examples/p_array.2.cc | 81 ++++++++++++++++++++++++++++++
mln/core/concept/proxy.hh | 6 ++
mln/core/concept/pseudo_site.hh | 57 ++++++++++++++++++++-
mln/core/concept/site_proxy.hh | 51 ++++++++++++++-----
mln/core/p_array.hh | 17 ++++++
mln/util/index.hh | 99 +++++++++++++++++++++++++++++++++++++
6 files changed, 297 insertions(+), 14 deletions(-)
Index: doc/tutorial/examples/p_array.2.cc
--- doc/tutorial/examples/p_array.2.cc (revision 0)
+++ doc/tutorial/examples/p_array.2.cc (revision 0)
@@ -0,0 +1,81 @@
+# include <mln/core/image2d.hh>
+# include <mln/core/p_array.hh>
+# include <mln/core/window.hh>
+
+# include <mln/debug/println.hh>
+# include <mln/level/fill.hh>
+
+
+template <typename A>
+mln::image2d<char> picture(const A& arr)
+{
+ using namespace mln;
+
+ image2d<char> ima(5, 5);
+ level::fill(ima, '-');
+
+ unsigned i = 0;
+ mln_piter(A) p(arr);
+ for_all(p)
+ ima(p) = '0' + i++;
+
+ debug::println(ima);
+ return ima;
+}
+
+
+template <typename I, typename W, typename P>
+void picture(const I& ima, const W& win, const P& p)
+{
+ std::cout << ima(p) << ": ";
+ mln_qiter(W) q(win, p);
+ for_all(q)
+ if (ima.has(q))
+ std::cout << ima(q) << ' ';
+ else
+ std::cout << "- ";
+ std::cout << std::endl;
+}
+
+
+int main()
+{
+ using namespace mln;
+
+ typedef p_array<point2d> Arr;
+ Arr arr;
+
+ point2d p(1,1);
+ arr.append(p);
+ dpoint2d dp[] = { right, right, down, down, left, left, up };
+ for (unsigned i = 0; i < 7; ++i)
+ p += dp[i], arr.append(p);
+
+ std::cout << "arr = " << arr << std::endl;
+ image2d<char> ima = picture(arr);
+
+ typedef window<util::dindex> W;
+ W win;
+ win.insert(-1).insert(0).insert(1);
+ std::cout << "win = " << win << std::endl
+ << std::endl;
+
+ util::index i;
+ mln_qiter_(W) j(win, i);
+ for (i = 0; i < arr.nsites(); i = i + 1)
+ {
+ std::cout << "i=" << i << ": ";
+ for_all(j)
+ if (arr.has(j))
+ {
+ mln_invariant( ima(arr[j]) == '0' + j.to_site());
+ std::cout << j << ' ';
+ }
+ else
+ std::cout << "- ";
+ std::cout << std::endl;
+ }
+
+ // FIXME: j does NOT convert to int because index is NOT a proxy
+ // NOTA: make index be a proxy, so equip it with every op it needs.
+}
Index: mln/core/p_array.hh
--- mln/core/p_array.hh (revision 2015)
+++ mln/core/p_array.hh (working copy)
@@ -38,6 +38,7 @@
# include <mln/core/internal/site_set_base.hh>
# include <mln/core/internal/pseudo_site_base.hh>
# include <mln/accu/bbox.hh>
+# include <mln/util/index.hh>
namespace mln
@@ -94,6 +95,9 @@
bool is_valid() const;
+ operator util::index() const { return i_; }
+
+
private:
const p_array<P>* arr_;
@@ -162,6 +166,19 @@
/// Test is \p p belongs to this site set.
bool has(const psite& p) const;
+ /// Test is \p i belongs to this site set.
+ bool has(const util::index& i) const
+ {
+ return i >= 0 && i < int(vect_.size());
+ }
+
+ /// Give the i-th element.
+ const P& operator[](const util::index& i) const
+ {
+ mln_precondition(has(i));
+ return vect_[i];
+ }
+
/// Test is index \p i belongs to this site set.
// FIXME: Add an overload "has(index)".
bool has_index(int i) const;
Index: mln/core/concept/proxy.hh
--- mln/core/concept/proxy.hh (revision 2015)
+++ mln/core/concept/proxy.hh (working copy)
@@ -148,6 +148,12 @@
ptr = & exact(obj);
}
+ template <typename T>
+ void get_adr( T *& ptr, T& obj)
+ {
+ ptr = & obj;
+ }
+
// Case 3: Fail to found!
template <typename T, typename O>
Index: mln/core/concept/pseudo_site.hh
--- mln/core/concept/pseudo_site.hh (revision 2015)
+++ mln/core/concept/pseudo_site.hh (working copy)
@@ -99,17 +99,70 @@
namespace if_possible
{
+ namespace internal
+ {
+
+ template <bool b> struct helper;
+
+ template <>
+ struct helper< /* is an Object */ true >
+ {
+
template <typename P>
- void change_target(Pseudo_Site<P>& p, const typename P::target_t& new_target)
+ void change_target(Pseudo_Site<P>& p, const typename P::target_t& new_target) const
{
exact(p).target() = & new_target;
}
template <typename O, typename D>
- void change_target(Object<O>&, const D&)
+ void change_target(Object<O>&, const D&) const
+ {
+ // No-op.
+ }
+
+ };
+
+ template <>
+ struct helper< /* NOT an Object */ false >
+ {
+ template <typename O, typename D>
+ void change_target(O&, const D&) const
{
// No-op.
}
+ };
+
+ } // namespace mln::if_possible::internal
+
+
+
+ // FIXME: Was:
+
+// template <typename P>
+// void change_target(Pseudo_Site<P>& p, const typename P::target_t& new_target)
+// {
+// exact(p).target() = & new_target;
+// }
+
+// template <typename O, typename D>
+// void change_target(Object<O>&, const D&)
+// {
+// // No-op.
+// }
+
+// template <typename P>
+// void change_target(P& p, const typename P::target_t& new_target)
+// {
+// exact(p).target() = & new_target;
+// }
+
+
+ template <typename O, typename D>
+ void change_target(O& o, const D& d)
+ {
+ enum { is_object = mlc_is_a(O, Object)::value };
+ mln::if_possible::internal::helper< is_object >().change_target(o, d);
+ }
} // end of namespace mln::if_possible
Index: mln/core/concept/site_proxy.hh
--- mln/core/concept/site_proxy.hh (revision 2015)
+++ mln/core/concept/site_proxy.hh (working copy)
@@ -109,9 +109,9 @@
// Access to site reference.
- template <typename P>
- const typename site_from<P>::ret&
- to_site(const Object<P>& p);
+ template <typename O>
+ const typename site_from<O>::ret&
+ to_site(const O& obj);
} // end of namespace internal
@@ -174,27 +174,54 @@
namespace deep
{
+ template <bool b> struct to_site_;
+
+ template <>
+ struct to_site_< /* is proxy = */ true >
+ {
template <typename P>
const typename site_from<P>::ret&
- to_site(const Site_Proxy<P>& p)
+ doit(const Site_Proxy<P>& p) const
{
return exact(p).to_site();
}
+ };
- template <typename P>
- const typename site_from<P>::ret&
- to_site(const Object<P>& p)
+ template <>
+ struct to_site_< /* is proxy = */ false >
+ {
+ template <typename O>
+ const O&
+ doit(const O& obj) const
{
- return exact(p);
+ return obj;
}
+ };
+
+ // FIXME: was:
+
+// template <typename P>
+// const typename site_from<P>::ret&
+// to_site(const Site_Proxy<P>& p)
+// {
+// return exact(p).to_site();
+// }
+
+// template <typename P>
+// const typename site_from<P>::ret&
+// to_site(const Object<P>& p)
+// {
+// return exact(p);
+// }
} // end of namespace internal::deep
- template <typename P>
- const typename site_from<P>::ret&
- to_site(const Object<P>& p)
+ template <typename O>
+ const typename site_from<O>::ret&
+ to_site(const O& obj)
{
- return deep::to_site(exact(p));
+ enum { is_proxy = mlc_is_a(O, Site_Proxy)::value };
+ return deep::to_site_< is_proxy >().doit(obj);
}
} // end of namespace mln::internal
Index: mln/util/index.hh
--- mln/util/index.hh (revision 0)
+++ mln/util/index.hh (revision 0)
@@ -0,0 +1,99 @@
+// Copyright (C) 2008 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef MLN_UTIL_INDEX_HH
+# define MLN_UTIL_INDEX_HH
+
+/*! \file mln/util/index.hh
+ *
+ * \brief Definition of an "index" type.
+ */
+
+# include <mln/core/concept/object.hh>
+
+
+namespace mln
+{
+
+ namespace util
+ {
+
+ // Fwd decl.
+ template <typename Tag> struct dindex_;
+
+
+ /*! \brief Index structure.
+ *
+ */
+ template <typename Tag = void>
+ struct index_ // : public Object< index_<Tag> >
+ {
+ typedef dindex_<Tag> dpsite;
+ typedef int coord;
+
+ int i_;
+
+ index_() {}
+ index_(int i) : i_(i) {}
+
+ operator int() const { return i_; }
+ };
+
+ typedef index_<void> index;
+
+
+ template <typename Tag = void>
+ struct dindex_ // : public Object< dindex_<Tag> >
+ {
+ typedef index_<Tag> psite;
+ typedef index_<Tag> site;
+ typedef int coord;
+
+ int i_;
+
+ dindex_() {}
+ dindex_(int i) : i_(i) {}
+
+ operator int() const { return i_; }
+ };
+
+ typedef dindex_<void> dindex;
+
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ // FIXME
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::util
+
+} // end of namespace mln
+
+
+#endif // ! MLN_UTIL_INDEX_HH
1
0
13 Jun '08
https://svn.lrde.epita.fr/svn/oln/branches/cleanup-2008/milena
Index: ChangeLog
from Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
Make relative iterators---qiter and niter---work.
* doc/tutorial/examples/image2d.cc (picture): New display proc.
(fill_null): New to illustrate a double loop.
(main): Add a test of window browsing from every array point.
Add a test about updating a relative site iterator.
* mln/core/macros.hh (mln_deduce): New.
* mln/core/window.hh (b_): Remove; it was useless and unused.
(sym): Remove return value to disambiguate w.r.t. geom::sym.
(include): Remove obsolete dpoints_piter.
* mln/core/internal/basic_window_impl.hh (vect): Rename as...
(std_vector): ...this.
(fwd_qiter, bkd_qiter): Update.
(include): New for iterators.
* mln/core/internal/neighborhood_impl_mixin.hh: New.
* mln/core/internal/site_relative_iterator_base.hh: New.
* mln/core/internal/site_iterator_base.hh: Add documentation.
(site_iterator_base_): Rename as...
(site_iterator_base): ...this.
(change_target, s_): New to factor code.
* mln/core/internal/site_set_iterator_base.hh: New.
* mln/core/internal/window_base.hh: Fix doc.
* mln/core/internal/neighborhood_base.hh: New; created from
window_base.
(is_centered, is_symmetric, sym): New factored code.
* mln/core/neighb.hh (neighb_): Rename as...
(neighb): ...this.
Update; that means remove about everything, now factored in
super classes.
(insert): Rename as...
(insert_): ...this.
* mln/core/box_piter.hh: Update inheritance.
(b_, target_): Remove cause factored; b_ is now s_.
(box_bkd_piter_): Fix ctor.
* mln/core/p_array_piter.hh: Likewise.
* mln/core/dpsites_piter.hh: New from dpoints_piter.
(start, next): Rename as...
(do_start_, do_next_): ...these.
Now rely on internal::site_relative_iterator_base.
(dps_, p_ref_, p_): Remove; obsolete cause factored.
(operator[]): Remove; now obsolete thanks to proxy_impl.
(compute_p_, update): New.
* mln/core/neighb2d.hh: Update.
* mln/core/p_array.hh (target_t): New type in psite.
(is_valid, p_, update_p_, has_index): New.
* mln/core/concept/pseudo_site.hh (change_target): New.
Add doc.
* mln/core/concept/site_iterator.hh (change_target): Move...
* mln/core/internal/site_iterator_base.hh: ...here.
* mln/core/concept/site_set.hh (insert_all): New.
* mln/core/image2d.hh (point): Re-new; to compile more easily.
(line_piter): Remove; it shall be re-inserted somewhere else.
(coord): Remove; useless.
(include): Remove dependance upon w_window which is not updated
yet.
* mln/level/fill.hh: Update.
* mln/geom/max_col.hh: Update.
* mln/geom/min_row.hh: Update.
doc/tutorial/examples/image2d.cc | 64 +++++
mln/core/box_piter.hh | 68 +----
mln/core/concept/pseudo_site.hh | 35 ++
mln/core/concept/site_iterator.hh | 20 -
mln/core/concept/site_set.hh | 15 +
mln/core/dpsites_piter.hh | 274 +++++++----------------
mln/core/image2d.hh | 9
mln/core/internal/basic_window_impl.hh | 23 +
mln/core/internal/neighborhood_base.hh | 66 ++++-
mln/core/internal/neighborhood_impl_mixin.hh | 64 +++++
mln/core/internal/site_iterator_base.hh | 49 +++-
mln/core/internal/site_relative_iterator_base.hh | 167 ++++++++++++++
mln/core/internal/site_set_iterator_base.hh | 87 +++++++
mln/core/internal/window_base.hh | 2
mln/core/macros.hh | 3
mln/core/neighb.hh | 114 +--------
mln/core/neighb2d.hh | 2
mln/core/p_array.hh | 66 +++++
mln/core/p_array_piter.hh | 42 +--
mln/core/window.hh | 18 -
mln/geom/max_col.hh | 6
mln/geom/min_row.hh | 6
mln/level/fill.hh | 3
23 files changed, 781 insertions(+), 422 deletions(-)
Index: doc/tutorial/examples/image2d.cc
--- doc/tutorial/examples/image2d.cc (revision 2014)
+++ doc/tutorial/examples/image2d.cc (working copy)
@@ -1,12 +1,48 @@
# include <mln/core/image2d.hh>
# include <mln/core/window2d.hh>
+# include <mln/core/p_array.hh>
+
+# include <mln/debug/iota.hh>
+# include <mln/debug/println.hh>
+
+# include <mln/core/neighb2d.hh>
+
+
+template <typename I, typename W, typename P>
+void picture(const I& ima, const W& win, const P& p)
+{
+ std::cout << ima(p) << ": ";
+ mln_qiter(W) q(win, p);
+ for_all(q)
+ if (ima.has(q))
+ std::cout << ima(q) << ' ';
+ else
+ std::cout << "- ";
+ std::cout << std::endl;
+}
+
+
+template <typename I, typename W>
+void fill_null(I& ima, const W& win)
+{
+ mln_piter(I) p(ima.domain());
+ mln_qiter(W) q(win, p);
+ for_all(p)
+ for_all(q)
+ if (ima.has(q))
+ ima(q) = 0;
+}
+
int main()
{
using namespace mln;
- image2d<char> ima(2, 3);
+ typedef image2d<unsigned> I;
+ I ima(2, 3, 0); // no border
+ debug::iota(ima);
+ debug::println(ima);
mln_invariant(ima.nsites() == 6);
window2d win;
@@ -15,4 +51,30 @@
.insert(0, -1)
.insert(-1,-1);
std::cout << win << std::endl;
+
+ {
+ mln_fwd_piter_(I) p(ima.domain());
+ for_all(p)
+ picture(ima, win, p);
+ }
+
+ {
+ typedef p_array<point2d> A;
+ A arr;
+ arr.insert_all(ima.domain());
+ mln_fwd_piter_(A) p(arr);
+ for_all(p)
+ picture(ima, win, p);
+
+ // FIXME: Move this new test in a separate file.
+ mln_psite_(A) c(arr, 0);
+ window2d it; it.insert(0,0);
+ mln_qiter_(window2d) q(it, c);
+ q.start();
+ q.to_site() == c.to_site();
+ c.inc_index();
+ mln_assertion(q.update().to_site() == c.to_site());
+ }
+
+ fill_null(ima, win);
}
Index: mln/core/macros.hh
--- mln/core/macros.hh (revision 2014)
+++ mln/core/macros.hh (working copy)
@@ -35,6 +35,9 @@
*/
+# define mln_deduce(T, A1, A2) typename T::A1::A2
+
+
// a
/// Shortcuts to access the argument type associated to T.
Index: mln/core/window.hh
--- mln/core/window.hh (revision 2014)
+++ mln/core/window.hh (working copy)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007 EPITA Research and Development Laboratory
+// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -77,13 +77,9 @@
*/
bool is_symmetric() const;
-
- /// Apply a central symmetry to the target window.
- window<D>& sym();
-
- protected:
-
- box_<mln_point(D)> b_;
+ /*! Apply a central symmetry to the target window.
+ */
+ void sym();
};
@@ -122,7 +118,7 @@
template <typename D>
inline
- window<D>&
+ void
window<D>::sym()
{
window<D> tmp;
@@ -130,7 +126,6 @@
for (unsigned i = 0; i < n; ++i)
tmp.insert(- this->dp(i));
*this = tmp;
- return *this;
}
template <typename D>
@@ -144,7 +139,4 @@
} // end of namespace mln
-# include <mln/core/dpoints_piter.hh>
-
-
#endif // ! MLN_CORE_WINDOW_HH
Index: mln/core/internal/basic_window_impl.hh
--- mln/core/internal/basic_window_impl.hh (revision 2014)
+++ mln/core/internal/basic_window_impl.hh (working copy)
@@ -42,8 +42,8 @@
{
// Fwd decls.
- template <typename D> class dpoints_fwd_piter;
- template <typename D> class dpoints_bkd_piter;
+ template <typename V> class dpsites_fwd_piter;
+ template <typename V> class dpsites_bkd_piter;
namespace internal
@@ -59,20 +59,21 @@
public:
- /*! \brief Site_Iterator type to browse the points of a basic window
- * whatever the ordering of delta-points.
- */
- typedef dpoints_fwd_piter<D> qiter;
/*! \brief Site_Iterator type to browse the points of a basic window
* w.r.t. the ordering of delta-points.
*/
- typedef dpoints_fwd_piter<D> fwd_qiter;
+ typedef dpsites_fwd_piter<E> fwd_qiter;
/*! \brief Site_Iterator type to browse the points of a basic window
* w.r.t. the reverse ordering of delta-points.
*/
- typedef dpoints_bkd_piter<D> bkd_qiter;
+ typedef dpsites_bkd_piter<E> bkd_qiter;
+
+ /*! \brief Site_Iterator type to browse the points of a basic window
+ * whatever the ordering of delta-points.
+ */
+ typedef fwd_qiter qiter;
/*! \brief Test if the window is empty (null size; no delta-point).
@@ -126,7 +127,6 @@
};
-
# ifndef MLN_INCLUDE_ONLY
template <typename D, typename E>
@@ -178,7 +178,7 @@
template <typename D, typename E>
inline
const std::vector<D>&
- basic_window_impl<D,E>::vect() const
+ basic_window_impl<D,E>::std_vector() const
{
return dps_.vect();
}
@@ -255,4 +255,7 @@
} // end of namespace mln
+# include <mln/core/dpsites_piter.hh>
+
+
#endif // ! MLN_CORE_INTERNAL_BASIC_WINDOW_IMPLHH
Index: mln/core/internal/neighborhood_impl_mixin.hh
--- mln/core/internal/neighborhood_impl_mixin.hh (revision 0)
+++ mln/core/internal/neighborhood_impl_mixin.hh (revision 0)
@@ -0,0 +1,64 @@
+// Copyright (C) 2008 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef MLN_CORE_INTERNAL_NEIGHBORHOOD_IMPL_MIXIN_HH
+# define MLN_CORE_INTERNAL_NEIGHBORHOOD_IMPL_MIXIN_HH
+
+/*! \file mln/core/internal/neighborhood_impl_mixin.hh
+ *
+ * \brief Definition of a mixin to turn a window implementation class
+ * into a neighborhood impl class.
+ */
+
+
+namespace mln
+{
+
+ namespace internal
+ {
+
+ template <typename W_impl, typename E>
+ struct neighborhood_impl_mixin : W_impl
+ {
+ /// Site_Iterator type to browse the neighborhood sites.
+ typedef typename W_impl::qiter niter;
+
+ /// Site_Iterator type to browse the neighborhood sites in the
+ /// forward way.
+ typedef typename W_impl::fwd_qiter fwd_niter;
+
+ /// Site_Iterator type to browse the neighborhood sites in the
+ /// backward way.
+ typedef typename W_impl::bkd_qiter bkd_niter;
+ };
+
+ } // end of namespace internal
+
+} // end of namespace mln
+
+
+#endif // ! MLN_CORE_INTERNAL_NEIGHBORHOOD_IMPL_MIXIN_HH
Index: mln/core/internal/site_relative_iterator_base.hh
--- mln/core/internal/site_relative_iterator_base.hh (revision 0)
+++ mln/core/internal/site_relative_iterator_base.hh (revision 0)
@@ -0,0 +1,167 @@
+// Copyright (C) 2008 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef MLN_CORE_SITE_RELATIVE_ITERATOR_BASE_HH
+# define MLN_CORE_SITE_RELATIVE_ITERATOR_BASE_HH
+
+/*! \file mln/core/site_relative_iterator_base.hh
+ *
+ * \brief Definition of forward and backward mln::dpoint_ based
+ * iterators.
+ *
+ * \todo Add a method to get the site set (if the center is defined) or
+ * the site set at a given center.
+ */
+
+# include <vector>
+# include <mln/core/internal/site_iterator_base.hh>
+
+
+namespace mln
+{
+
+ namespace internal
+ {
+
+ /*! \brief A generic forward iterator on points of windows and of
+ * neighborhoods.
+ *
+ * The parameter \c S is the type of std::vector enclosing
+ * structure.
+ */
+ template <typename S, typename E>
+ class site_relative_iterator_base : public site_iterator_base< S, E >
+ {
+ public:
+
+ /// Constructor witout argument.
+ site_relative_iterator_base();
+
+ template <typename P>
+ void center_at(const P& c);
+
+ /// Test the iterator validity.
+ bool is_valid_() const;
+
+ /// Invalidate the iterator.
+ void invalidate_();
+
+ /// Start an iteration.
+ void start_();
+
+ /// Go to the next point.
+ void next_();
+
+ /// The psite around which this iterator moves.
+ const mln_psite(S)& center() const;
+
+ /// Overriding that adds a test to prevent getting an invalid
+ /// iterator when its center has moved. Some sub-classes
+ /// provide an update() method for the client to say that she
+ /// really want to read the iterator just after the center has
+ /// changed.
+ const mln_psite(S)& unproxy() const;
+
+ protected:
+
+ const mln_psite(S)* c_;
+ };
+
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename S, typename E>
+ inline
+ site_relative_iterator_base<S,E>::site_relative_iterator_base()
+ : c_(0)
+ {
+ void (E::*m1)() = & E::do_start_;
+ m1 = 0;
+ void (E::*m2)() = & E::do_next_;
+ m2 = 0;
+ mln_psite(S) (E::*m3)() const = & E::compute_p_;
+ m3 = 0;
+ }
+
+ template <typename S, typename E>
+ template <typename P>
+ inline
+ void
+ site_relative_iterator_base<S,E>::center_at(const P& c)
+ {
+ internal::get_adr(c_, c);
+ this->invalidate();
+ }
+
+ template <typename S, typename E>
+ inline
+ void
+ site_relative_iterator_base<S,E>::start_()
+ {
+ exact(this)->do_start_();
+ if (this->is_valid())
+ this->p_ = exact(this)->compute_p_();
+ }
+
+ template <typename S, typename E>
+ inline
+ void
+ site_relative_iterator_base<S,E>::next_()
+ {
+ exact(this)->do_next_();
+ if (this->is_valid())
+ this->p_ = exact(this)->compute_p_();
+ }
+
+ template <typename S, typename E>
+ inline
+ const mln_psite(S)&
+ site_relative_iterator_base<S,E>::center() const
+ {
+ mln_precondition(c_ != 0);
+ return *c_;
+ }
+
+ template <typename S, typename E>
+ inline
+ const mln_psite(S)&
+ site_relative_iterator_base<S,E>::unproxy() const
+ {
+ mln_psite(S) p_now = exact(this)->compute_p_();
+ mln_assertion(p_now == this->p_);
+ return this->p_;
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::internal
+
+} // end of namespace mln
+
+
+#endif // ! MLN_CORE_SITE_RELATIVE_ITERATOR_BASE_HH
Index: mln/core/internal/site_iterator_base.hh
--- mln/core/internal/site_iterator_base.hh (revision 2014)
+++ mln/core/internal/site_iterator_base.hh (working copy)
@@ -34,6 +34,7 @@
*/
# include <mln/core/concept/site_iterator.hh>
+# include <mln/core/concept/pseudo_site.hh> // Use of if_possible::change_target.
namespace mln
@@ -44,10 +45,15 @@
/*! \internal A base class for site iterators.
*
+ * NEVER DIRECTLY DERIVE FROM THIS CLASS.
+ *
+ * Instead derive from EITHER site_set_iterator_base OR
+ * site_relative_iterator_base.
+ *
* Parameter \c S is the targeted site set type.
*/
template <typename S, typename E>
- struct site_iterator_base_ : Site_Iterator<E>,
+ struct site_iterator_base : Site_Iterator<E>,
proxy_impl< mln_psite(S), E>,
@@ -57,7 +63,7 @@
{
/// The associated site type (as a Site_Proxy).
- typedef mln_site(S) site; // typename internal::site_from<P>::ret site;
+ typedef mln_site(S) site;
/// Return the site it points to (as a Site_Proxy).
const mln_site(S)& to_site() const;
@@ -80,14 +86,20 @@
/// Give the subject (required by the Proxy interface).
const mln_psite(S)& unproxy() const;
- /// Access to the target address; default impl.
+ /// Give the target address. It might be 0.
const S*& target_();
+ /// Change the iterator target.
+ void change_target(const S& s);
+
protected:
- site_iterator_base_();
+ site_iterator_base();
- /// The site designated by this iterator.
+ /// The target.
+ const S* s_;
+
+ /// The psite designated by this iterator.
mln_psite(S) p_;
};
@@ -96,13 +108,13 @@
template <typename S, typename E>
inline
- site_iterator_base_<S, E>::site_iterator_base_()
+ site_iterator_base<S, E>::site_iterator_base()
{
}
template <typename S, typename E>
inline
- site_iterator_base_<S, E>::operator mln_site(S)() const
+ site_iterator_base<S, E>::operator mln_site(S)() const
{
typedef proxy_impl<mln_psite(S), E> super;
mln_precondition(exact(this)->is_valid());
@@ -112,16 +124,16 @@
template <typename S, typename E>
inline
const mln_site(S)&
- site_iterator_base_<S, E>::to_site() const
+ site_iterator_base<S, E>::to_site() const
{
mln_precondition(exact(*this).is_valid()); // FIXME: OK?
- return internal::to_site(p_);
+ return internal::to_site( exact(this)->unproxy() );
}
template <typename S, typename E>
inline
const mln_psite(S)&
- site_iterator_base_<S, E>::unproxy() const
+ site_iterator_base<S, E>::unproxy() const
{
return p_;
}
@@ -129,9 +141,22 @@
template <typename S, typename E>
inline
const S*&
- site_iterator_base_<S, E>::target_()
+ site_iterator_base<S, E>::target_()
+ {
+ return s_;
+ }
+
+ template <typename S, typename E>
+ inline
+ void
+ site_iterator_base<S, E>::change_target(const S& s)
{
- return this->p_.target();
+ s_ = & s;
+ // p_ might be also updated since it can hold a pointer towards
+ // the set it designates, so:
+ if_possible::change_target(p_, s);
+ // Last:
+ this->invalidate();
}
#endif // ! MLN_INCLUDE_ONLY
Index: mln/core/internal/site_set_iterator_base.hh
--- mln/core/internal/site_set_iterator_base.hh (revision 0)
+++ mln/core/internal/site_set_iterator_base.hh (revision 0)
@@ -0,0 +1,87 @@
+// Copyright (C) 2008 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef MLN_CORE_INTERNAL_SITE_SET_ITERATOR_BASE_HH
+# define MLN_CORE_INTERNAL_SITE_SET_ITERATOR_BASE_HH
+
+/*! \file mln/core/internal/site_set_iterator_base.hh
+ *
+ * \brief Base class to factor code for iterator classes directly
+ * working on site sets.
+ */
+
+# include <mln/core/internal/site_iterator_base.hh>
+
+
+namespace mln
+{
+
+ namespace internal
+ {
+
+ /*! \internal A base class for site iterators.
+ *
+ * Parameter \c S is the targeted site set type.
+ */
+ template <typename S, typename E>
+ struct site_set_iterator_base : site_iterator_base<S, E>
+ {
+
+ /// Give the site set that this iterator browses.
+ const S& site_set() const;
+
+ protected:
+
+ site_set_iterator_base();
+ };
+
+
+#ifndef MLN_INCLUDE_ONLY
+
+ template <typename S, typename E>
+ inline
+ site_set_iterator_base<S, E>::site_set_iterator_base()
+ {
+ }
+
+ template <typename S, typename E>
+ inline
+ const S&
+ site_set_iterator_base<S, E>::site_set() const
+ {
+ mln_precondition(this->s_ != 0);
+ return *this->s_;
+ }
+
+#endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace internal
+
+} // end of namespace mln
+
+
+#endif // ! MLN_CORE_INTERNAL_SITE_SET_ITERATOR_BASE_HH
Index: mln/core/internal/window_base.hh
--- mln/core/internal/window_base.hh (revision 2014)
+++ mln/core/internal/window_base.hh (working copy)
@@ -30,7 +30,7 @@
/*! \file mln/core/internal/window_base.hh
*
- * \brief Definition of a base class for site set classes.
+ * \brief Definition of a base class for window classes.
*/
# include <mln/core/concept/window.hh>
Index: mln/core/internal/neighborhood_base.hh
--- mln/core/internal/neighborhood_base.hh (revision 2013)
+++ mln/core/internal/neighborhood_base.hh (working copy)
@@ -25,15 +25,15 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef MLN_CORE_INTERNAL_WINDOW_BASE_HH
-# define MLN_CORE_INTERNAL_WINDOW_BASE_HH
+#ifndef MLN_CORE_INTERNAL_NEIGHBORHOOD_BASE_HH
+# define MLN_CORE_INTERNAL_NEIGHBORHOOD_BASE_HH
-/*! \file mln/core/internal/window_base.hh
+/*! \file mln/core/internal/neighborhood_base.hh
*
- * \brief Definition of a base class for site set classes.
+ * \brief Definition of a base class for neighborhood classes.
*/
-# include <mln/core/concept/window.hh>
+# include <mln/core/concept/neighborhood.hh>
namespace mln
@@ -43,12 +43,12 @@
{
- /*! \internal A base class for window classes.
+ /*! \internal A base class for neighborhood classes.
*
* \p D is a dpsite type.
*/
template <typename D, typename E>
- struct window_base : public Window<E>
+ struct neighborhood_base : public Neighborhood<E>
{
/// DPsite associated type.
@@ -60,17 +60,61 @@
/// Site associated type.
typedef mln_site(D) site;
+
+ /*! \brief Test (as a window) if it is centered so (as a
+ * neighborhood) return false.
+ *
+ * \return Always false.
+ */
+ bool is_centered() const;
+
+ /*! \brief Test (as a window) if it is symmetric so (as a
+ * neighborhood) return true.
+ *
+ * \return Always true.
+ */
+ bool is_symmetric() const;
+
+ /*! Apply (as a window) a central symmetry so (as a
+ neighborhood) it is a no-op.
+ */
+ void sym();
+
protected:
- window_base();
+ neighborhood_base();
};
# ifndef MLN_INCLUDE_ONLY
- template <typename S, typename E>
+ template <typename D, typename E>
+ inline
+ neighborhood_base<D,E>::neighborhood_base()
+ {
+ }
+
+ template <typename D, typename E>
+ inline
+ bool
+ neighborhood_base<D,E>::is_centered() const
+ {
+ return false;
+ }
+
+ template <typename D, typename E>
+ inline
+ bool
+ neighborhood_base<D,E>::is_symmetric() const
+ {
+ return true;
+ }
+
+ template <typename D, typename E>
inline
- window_base<S,E>::window_base()
+ void
+ neighborhood_base<D,E>::sym()
{
+ // No-op.
}
# endif // ! MLN_INCLUDE_ONLY
@@ -80,4 +124,4 @@
} // end of namespace mln
-#endif // ! MLN_CORE_INTERNAL_WINDOW_BASE_HH
+#endif // ! MLN_CORE_INTERNAL_NEIGHBORHOOD_BASE_HH
Index: mln/core/neighb.hh
--- mln/core/neighb.hh (revision 2014)
+++ mln/core/neighb.hh (working copy)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007 EPITA Research and Development Laboratory
+// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -30,21 +30,17 @@
/*! \file mln/core/neighb.hh
*
- * \brief Definition of the generic neighborhood class mln::neighb_.
+ * \brief Definition of the generic neighborhood class mln::neighb.
*/
-# include <mln/core/concept/neighborhood.hh>
-# include <mln/core/internal/dpoints_base.hh>
-# include <mln/core/dpoint.hh>
+# include <mln/core/internal/neighborhood_base.hh>
+# include <mln/core/internal/basic_window_impl.hh>
+# include <mln/core/internal/neighborhood_impl_mixin.hh>
namespace mln
{
- // fwd decls
- template <typename D> class dpoints_fwd_piter;
- template <typename D> class dpoints_bkd_piter;
-
/*! \brief Generic neighborhood class.
*
@@ -52,58 +48,20 @@
* The parameter is \c D, type of delta-point.
*/
template <typename D>
- struct neighb_ : public Neighborhood< neighb_<D> >,
- public internal::dpoints_base_<D, neighb_<D> >
+ struct neighb : internal::neighborhood_base< D, neighb<D> >,
+ internal::neighborhood_impl_mixin< internal::basic_window_impl< D, neighb<D> >,
+ neighb<D> >
{
- /// Dpoint associated type.
- typedef D dpoint;
-
- /// Point associated type.
- typedef mln_point(D) point;
-
- /*! \brief Site_Iterator type to browse the points of a generic
- * neighborhood w.r.t. the ordering of delta-points.
- */
- typedef dpoints_fwd_piter<D> fwd_niter;
-
- /*! \brief Site_Iterator type to browse the points of a generic
- * neighborhood w.r.t. the reverse ordering of delta-points.
- */
- typedef dpoints_bkd_piter<D> bkd_niter;
-
- /*! \brief Same as fwd_niter.
- */
- typedef fwd_niter niter;
-
/*! \brief Constructor without argument.
*
* The constructed neighborhood is empty. You have to use insert()
* to proceed to the neighborhood definition.
*/
- neighb_();
+ neighb();
- /*! \brief Insert a delta-point \p dp in the neighborhood
- * definition.
- *
- * \param[in] dp The delta-point to insert.
- *
- * This method also insert the symmetrical delta-point, - \p dp,
- * in the neighborhood definition; thus the client has not to
- * ensure the symmetry property; that is automatic.
- */
- neighb_<D>& insert(const D& dp);
-
- /// \{ Insertion of a delta-point with different numbers of
- /// arguments (coordinates) w.r.t. the dimension.
- neighb_<D>& insert(const mln_coord(D)& dind); // For 1D.
-
- neighb_<D>& insert(const mln_coord(D)& drow,
- const mln_coord(D)& dcol); // For 2D.
-
- neighb_<D>& insert(const mln_coord(D)& dsli,
- const mln_coord(D)& drow,
- const mln_coord(D)& dcol); // For 3D.
- /// \}
+ // Overridden from internal::basic_window_impl so that it also
+ // inserts \a -dp.
+ neighb<D>& insert_(const D& dp);
};
@@ -111,58 +69,26 @@
template <typename D>
inline
- neighb_<D>::neighb_()
+ neighb<D>::neighb()
{
}
template <typename D>
inline
- neighb_<D>&
- neighb_<D>::insert(const D& dp)
+ neighb<D>&
+ neighb<D>::insert_(const D& dp)
{
- mln_precondition(! has(dp));
- typedef internal::set_of_<D> super;
- this->super::insert( dp);
- this->super::insert(-dp);
+ typedef neighb<D> self;
+ typedef internal::basic_window_impl< D, neighb<D> > win_impl;
+ typedef internal::neighborhood_impl_mixin< win_impl, neighb<D> > super_;
+ this->super_::insert_( dp);
+ this->super_::insert_(-dp);
return *this;
}
- template <typename D>
- inline
- neighb_<D>&
- neighb_<D>::insert(const mln_coord(D)& dind)
- {
- D dp(dind);
- mln_precondition(! has(dp));
- return this->insert(dp);
- }
-
- template <typename D>
- inline
- neighb_<D>&
- neighb_<D>::insert(const mln_coord(D)& drow, const mln_coord(D)& dcol)
- {
- D dp(drow, dcol);
- mln_precondition(! has(dp));
- return this->insert(dp);
- }
-
- template <typename D>
- inline
- neighb_<D>&
- neighb_<D>::insert(const mln_coord(D)& dsli, const mln_coord(D)& drow, const mln_coord(D)& dcol)
- {
- D dp(dsli, drow, dcol);
- mln_precondition(! has(dp));
- return this->insert(dp);
- }
-
# endif // ! MLN_INCLUDE_ONLY
} // end of namespace mln
-# include <mln/core/dpoints_piter.hh>
-
-
#endif // ! MLN_CORE_NEIGHB_HH
Index: mln/core/box_piter.hh
--- mln/core/box_piter.hh (revision 2014)
+++ mln/core/box_piter.hh (working copy)
@@ -33,7 +33,7 @@
* \brief Definition of iterators on points of boxes.
*/
-# include <mln/core/internal/site_iterator_base.hh>
+# include <mln/core/internal/site_set_iterator_base.hh>
# include <mln/core/concept/box.hh>
@@ -47,11 +47,11 @@
* \see mln::box_
*/
template <typename P>
- class box_fwd_piter_ : public internal::site_iterator_base_< box_<P>,
+ class box_fwd_piter_ : public internal::site_set_iterator_base< box_<P>,
box_fwd_piter_<P> >
{
typedef box_fwd_piter_<P> self_;
- typedef internal::site_iterator_base_< box_<P>, self_ > super_;
+ typedef internal::site_iterator_base< box_<P>, self_ > super_;
public:
@@ -76,13 +76,10 @@
/// Go to the next point.
void next_();
- /// Give the site set target address.
- const box_<P>*& target_();
-
- private:
+ protected:
using super_::p_;
- const box_<P>* b_;
+ using super_::s_;
};
@@ -94,11 +91,11 @@
* \see mln::box_
*/
template <typename P>
- class box_bkd_piter_ : public internal::site_iterator_base_< box_<P>,
+ class box_bkd_piter_ : public internal::site_iterator_base< box_<P>,
box_bkd_piter_<P> >
{
typedef box_bkd_piter_<P> self_;
- typedef internal::site_iterator_base_< box_<P>, self_ > super_;
+ typedef internal::site_iterator_base< box_<P>, self_ > super_;
public:
@@ -123,13 +120,10 @@
/// Go to the next point.
void next_();
- /// Give the site set target address.
- const box_<P>*& target_();
-
- private:
+ protected:
using super_::p_;
- const box_<P>* b_;
+ using super_::s_;
};
@@ -144,7 +138,7 @@
inline
box_fwd_piter_<P>::box_fwd_piter_(const box_<P>& b)
{
- change_target(b);
+ this->change_target(b);
}
template <typename P>
@@ -152,7 +146,7 @@
bool
box_fwd_piter_<P>::is_valid_() const
{
- return p_[0] != b_->pmax()[0] + 1;
+ return p_[0] != s_->pmax()[0] + 1;
}
template <typename P>
@@ -160,7 +154,7 @@
void
box_fwd_piter_<P>::invalidate_()
{
- p_[0] = b_->pmax()[0] + 1;
+ p_[0] = s_->pmax()[0] + 1;
}
template <typename P>
@@ -168,7 +162,7 @@
void
box_fwd_piter_<P>::start_()
{
- p_ = b_->pmin();
+ p_ = s_->pmin();
}
template <typename P>
@@ -177,25 +171,17 @@
box_fwd_piter_<P>::next_()
{
for (int i = dim - 1; i >= 0; --i)
- if (p_[i] == b_->pmax()[i])
- p_[i] = b_->pmin()[i];
+ if (p_[i] == s_->pmax()[i])
+ p_[i] = s_->pmin()[i];
else
{
++p_[i];
break;
}
- if (p_ == b_->pmin())
+ if (p_ == s_->pmin())
invalidate_();
}
- template <typename P>
- inline
- const box_<P>*&
- box_fwd_piter_<P>::target_()
- {
- return b_;
- }
-
// box_bkd_piter_<P>
@@ -203,7 +189,7 @@
inline
box_bkd_piter_<P>::box_bkd_piter_(const box_<P>& b)
{
- change_target(&b);
+ this->change_target(b);
}
template <typename P>
@@ -211,7 +197,7 @@
bool
box_bkd_piter_<P>::is_valid_() const
{
- return p_[0] != b_->pmin()[0] - 1;
+ return p_[0] != s_->pmin()[0] - 1;
}
template <typename P>
@@ -219,7 +205,7 @@
void
box_bkd_piter_<P>::invalidate_()
{
- p_[0] = b_->pmin()[0] - 1;
+ p_[0] = s_->pmin()[0] - 1;
}
template <typename P>
@@ -227,7 +213,7 @@
void
box_bkd_piter_<P>::start_()
{
- p_ = b_->pmax();
+ p_ = s_->pmax();
}
template <typename P>
@@ -236,25 +222,17 @@
box_bkd_piter_<P>::next_()
{
for (int i = dim - 1; i >= 0; --i)
- if (p_[i] == b_->pmin()[i])
- p_[i] = b_->pmax()[i];
+ if (p_[i] == s_->pmin()[i])
+ p_[i] = s_->pmax()[i];
else
{
--p_[i];
break;
}
- if (p_ == b_->pmax())
+ if (p_ == s_->pmax())
invalidate_();
}
- template <typename P>
- inline
- const box_<P>*&
- box_bkd_piter_<P>::target_()
- {
- return b_;
- }
-
# endif // ! MLN_INCLUDE_ONLY
} // end of namespace mln
Index: mln/core/p_array_piter.hh
--- mln/core/p_array_piter.hh (revision 2014)
+++ mln/core/p_array_piter.hh (working copy)
@@ -32,7 +32,7 @@
/// \brief Definition of point iterators on mln::p_array.
# include <mln/core/p_array.hh>
-# include <mln/core/internal/site_iterator_base.hh>
+# include <mln/core/internal/site_set_iterator_base.hh>
namespace mln
@@ -42,14 +42,11 @@
template <typename P>
class p_array_fwd_piter_
:
- public internal::site_iterator_base_< p_array<P>,
+ public internal::site_set_iterator_base< p_array<P>,
p_array_fwd_piter_<P> >
{
typedef p_array_fwd_piter_<P> self;
- typedef internal::site_iterator_base_<p_array<P>, self> super;
-
- protected:
- using super::p_;
+ typedef internal::site_set_iterator_base<p_array<P>, self> super;
public:
@@ -73,6 +70,11 @@
/// Return the current index.
int index() const;
+
+ protected:
+
+ using super::p_;
+ using super::s_;
};
@@ -85,14 +87,11 @@
template <typename P>
class p_array_bkd_piter_
:
- public internal::site_iterator_base_< p_array<P>,
+ public internal::site_set_iterator_base< p_array<P>,
p_array_bkd_piter_<P> >
{
typedef p_array_bkd_piter_<P> self;
- typedef internal::site_iterator_base_<p_array<P>, self> super;
-
- protected:
- using super::p_;
+ typedef internal::site_set_iterator_base<p_array<P>, self> super;
public:
@@ -116,6 +115,11 @@
/// Return the current index.
int index() const;
+
+ protected:
+
+ using super::p_;
+ using super::s_;
};
@@ -148,7 +152,7 @@
p_array_fwd_piter_<P>::is_valid_() const
{
mln_invariant(p_.index() >= 0);
- return p_.index() < int(p_.target()->nsites());
+ return p_.index() < int(s_->nsites());
}
template <typename P>
@@ -156,7 +160,7 @@
void
p_array_fwd_piter_<P>::invalidate_()
{
- p_.index() = int(p_.target()->nsites());
+ p_.change_index(s_->nsites());
}
template <typename P>
@@ -164,7 +168,7 @@
void
p_array_fwd_piter_<P>::start_()
{
- p_.index() = 0;
+ p_.change_index(0);
}
template <typename P>
@@ -172,7 +176,7 @@
void
p_array_fwd_piter_<P>::next_()
{
- ++p_.index();
+ p_.inc_index();
}
template <typename P>
@@ -206,7 +210,7 @@
bool
p_array_bkd_piter_<P>::is_valid_() const
{
- mln_invariant(p_.index() < int(p_.target()->nsites()));
+ mln_invariant(p_.index() < int(s_->nsites()));
return p_.index() >= 0;
}
@@ -215,7 +219,7 @@
void
p_array_bkd_piter_<P>::invalidate_()
{
- p_.index() = -1;
+ p_.change_index(-1);
}
template <typename P>
@@ -223,7 +227,7 @@
void
p_array_bkd_piter_<P>::start_()
{
- p_.index() = int(p_.target()->nsites()) - 1;
+ p_.change_index(s_->nsites() - 1);
}
template <typename P>
@@ -231,7 +235,7 @@
void
p_array_bkd_piter_<P>::next_()
{
- --p_.index();
+ p_.dec_index();
}
template <typename P>
Index: mln/core/dpsites_piter.hh
--- mln/core/dpsites_piter.hh (revision 2013)
+++ mln/core/dpsites_piter.hh (working copy)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007 EPITA Research and Development Laboratory
+// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -25,18 +25,17 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef MLN_CORE_DPOINTS_PITER_HH
-# define MLN_CORE_DPOINTS_PITER_HH
+#ifndef MLN_CORE_DPSITES_PITER_HH
+# define MLN_CORE_DPSITES_PITER_HH
-/*! \file mln/core/dpoints_piter.hh
+/*! \file mln/core/dpsites_piter.hh
*
* \brief Definition of forward and backward mln::dpoint_ based
* iterators.
*/
# include <vector>
-# include <mln/core/internal/site_iterator_base.hh>
-# include <mln/core/concept/point_site.hh>
+# include <mln/core/internal/site_relative_iterator_base.hh>
namespace mln
@@ -45,10 +44,12 @@
/*! \brief A generic forward iterator on points of windows and of
* neighborhoods.
*
- * The parameter \c D is the type of delta-points.
+ * The parameter \c V is the type of std::vector enclosing
+ * structure.
*/
- template <typename D>
- class dpoints_fwd_piter : public internal::site_iterator_base_< mln_point(D), dpoints_fwd_piter<D> >
+ template <typename V>
+ class dpsites_fwd_piter
+ : public internal::site_relative_iterator_base< V, dpsites_fwd_piter<V> >
{
public:
@@ -57,56 +58,41 @@
* \param[in] dps Object that can provide an array of delta-points.
* \param[in] p_ref Center point to iterate around.
*/
- template <typename Dps, typename Pref>
- dpoints_fwd_piter(const Dps& dps, // FIXME: explicitly set_of_<D>?
- const Point_Site<Pref>& p_ref);
-
- /// Convertion to point.
- operator mln_point(D) () const;
-
- /// Reference to the corresponding point.
- const mln_point(D)& to_point() const;
+ template <typename P>
+ dpsites_fwd_piter(const V& v, const P& c);
/// Test the iterator validity.
- bool is_valid() const;
+ bool is_valid_() const;
/// Invalidate the iterator.
- void invalidate();
+ void invalidate_();
/// Start an iteration.
- void start();
+ void do_start_();
/// Go to the next point.
- void next_();
-
- /// Give the i-th coordinate.
- mln_coord(D) operator[](unsigned i) const;
+ void do_next_();
- /// The point around which this iterator moves.
- const mln_point(D)& center_point() const;
+ /// Compute the current psite.
+ mln_psite(V) compute_p_() const;
- /// Force this iterator to update its location to take into
- /// account that its center point may have moved.
- void update();
+ dpsites_fwd_piter<V>& update();
protected:
- const std::vector<D>& dps_;
- const mln_point(D)& p_ref_; // reference point (or "center point")
-
unsigned i_;
- mln_point(D) p_; // location of this iterator; p_ makes this iterator be
- // itself a potential center point.
};
/*! \brief A generic backward iterator on points of windows and of
* neighborhoods.
*
- * The parameter \c D is the type of delta-points.
+ * The parameter \c V is the type of std::vector enclosing
+ * structure.
*/
- template <typename D>
- class dpoints_bkd_piter : public internal::site_iterator_base_< mln_point(D), dpoints_bkd_piter<D> >
+ template <typename V>
+ class dpsites_bkd_piter :
+ public internal::site_relative_iterator_base< V, dpsites_bkd_piter<V> >
{
public:
@@ -115,248 +101,166 @@
* \param[in] dps Object that can provide an array of delta-points.
* \param[in] p_ref Center point to iterate around.
*/
- template <typename Dps, typename Pref>
- dpoints_bkd_piter(const Dps& dps, // FIXME: explicitly set_of_<D>?
- const Point_Site<Pref>& p_ref);
-
- /// Convertion to point.
- operator mln_point(D) () const;
-
- /// Reference to the corresponding point.
- const mln_point(D)& to_point() const;
+ template <typename P>
+ dpsites_bkd_piter(const V& v, const P& c);
/// Test the iterator validity.
- bool is_valid() const;
+ bool is_valid_() const;
/// Invalidate the iterator.
- void invalidate();
+ void invalidate_();
/// Start an iteration.
- void start();
+ void do_start_();
/// Go to the next point.
- void next_();
-
- /// Give the i-th coordinate.
- mln_coord(D) operator[](unsigned i) const;
+ void do_next_();
- /// The point around which this iterator moves.
- const mln_point(D)& center_point() const;
+ /// Compute the current psite.
+ mln_psite(V) compute_p_() const;
- /// Force this iterator to update its location to take into
- /// account that its center point may have moved.
- void update();
+ dpsites_fwd_piter<V>& update();
protected:
- const std::vector<D>& dps_;
- const mln_point(D)& p_ref_; // reference point (or "center point")
-
int i_;
- mln_point(D) p_; // location of this iterator; p_ makes this iterator be
- // itself a potential center point.
};
# ifndef MLN_INCLUDE_ONLY
- template <typename D>
- template <typename Dps, typename Pref>
- inline
- dpoints_fwd_piter<D>::dpoints_fwd_piter(const Dps& dps,
- const Point_Site<Pref>& p_ref)
- : dps_(exact(dps).vect()),
- p_ref_(exact(p_ref).to_point())
- {
- invalidate();
- }
- template <typename D>
- inline
- dpoints_fwd_piter<D>::operator mln_point(D) () const
- {
- mln_precondition(is_valid());
- return p_;
- }
+ // Forward.
+
- template <typename D>
+ template <typename V>
+ template <typename P>
inline
- const mln_point(D)&
- dpoints_fwd_piter<D>::to_point() const
+ dpsites_fwd_piter<V>::dpsites_fwd_piter(const V& v, const P& c)
{
- return p_;
+ this->change_target(v);
+ this->center_at(c);
}
- template <typename D>
+ template <typename V>
inline
bool
- dpoints_fwd_piter<D>::is_valid() const
+ dpsites_fwd_piter<V>::is_valid_() const
{
- return i_ != dps_.size();
+ return i_ != this->s_->std_vector().size();
}
- template <typename D>
+ template <typename V>
inline
void
- dpoints_fwd_piter<D>::invalidate()
+ dpsites_fwd_piter<V>::invalidate_()
{
- i_ = dps_.size();
+ i_ = this->s_->std_vector().size();
}
- template <typename D>
+ template <typename V>
inline
void
- dpoints_fwd_piter<D>::start()
+ dpsites_fwd_piter<V>::do_start_()
{
i_ = 0;
- update();
}
- template <typename D>
+ template <typename V>
inline
void
- dpoints_fwd_piter<D>::next_()
+ dpsites_fwd_piter<V>::do_next_()
{
++i_;
- update();
- }
-
- template <typename D>
- inline
- const mln_point(D)&
- dpoints_fwd_piter<D>::center_point() const
- {
- return p_ref_;
}
- template <typename D>
+ template <typename V>
inline
- void
- dpoints_fwd_piter<D>::update()
+ mln_psite(V)
+ dpsites_fwd_piter<V>::compute_p_() const
{
- if (is_valid())
- p_ = p_ref_ + dps_[i_];
+ return *this->c_ + this->s_->std_vector()[i_];
}
- template <typename D>
+ template <typename V>
inline
- mln_coord(D)
- dpoints_fwd_piter<D>::operator[](unsigned i) const
+ dpsites_fwd_piter<V>&
+ dpsites_fwd_piter<V>::update()
{
- mln_precondition(is_valid());
-
- // below we test that no update is required
- // meaning that p_ref_ has not moved or that
- // the user has explicitly called update()
- mln_precondition(p_ref_ + dps_[i_] == p_);
- // FIXME: Explain this issue in the class documentation...
-
- return p_[i];
+ mln_precondition(this->s_ && this->c_);
+ this->p_ = compute_p_();
+ mln_postcondition(this->is_valid());
+ return *this;
}
+ // Backward.
- template <typename D>
- template <typename Dps, typename Pref>
- inline
- dpoints_bkd_piter<D>::dpoints_bkd_piter(const Dps& dps,
- const Point_Site<Pref>& p_ref)
- : dps_(exact(dps).vect()),
- p_ref_(exact(p_ref).to_point())
- {
- invalidate();
- }
-
- template <typename D>
- inline
- dpoints_bkd_piter<D>::operator mln_point(D) () const
- {
- mln_precondition(is_valid());
- return p_;
- }
- template <typename D>
+ template <typename V>
+ template <typename P>
inline
- const mln_point(D)&
- dpoints_bkd_piter<D>::to_point() const
+ dpsites_bkd_piter<V>::dpsites_bkd_piter(const V& v, const P& c)
{
- return p_;
+ this->change_target(v);
+ this->center_at(c);
}
- template <typename D>
+ template <typename V>
inline
bool
- dpoints_bkd_piter<D>::is_valid() const
+ dpsites_bkd_piter<V>::is_valid_() const
{
- unsigned i = i_;
-
- return i < dps_.size();
+ return i_ != -1;
}
- template <typename D>
+ template <typename V>
inline
void
- dpoints_bkd_piter<D>::invalidate()
+ dpsites_bkd_piter<V>::invalidate_()
{
i_ = -1;
}
- template <typename D>
+ template <typename V>
inline
void
- dpoints_bkd_piter<D>::start()
+ dpsites_bkd_piter<V>::do_start_()
{
- i_ = dps_.size() - 1;
- update();
+ i_ = this->s_->std_vector().size() - 1;
}
- template <typename D>
+ template <typename V>
inline
void
- dpoints_bkd_piter<D>::next_()
+ dpsites_bkd_piter<V>::do_next_()
{
--i_;
- update();
}
- template <typename D>
+ template <typename V>
inline
- const mln_point(D)&
- dpoints_bkd_piter<D>::center_point() const
+ mln_psite(V)
+ dpsites_bkd_piter<V>::compute_p_() const
{
- return p_ref_;
+ return *this->c_ + this->s_->std_vector()[i_];
}
- template <typename D>
+ template <typename V>
inline
- void
- dpoints_bkd_piter<D>::update()
+ dpsites_fwd_piter<V>&
+ dpsites_bkd_piter<V>::update()
{
- if (is_valid())
- p_ = p_ref_ + dps_[i_];
+ mln_precondition(this->s_ && this->c_);
+ this->p_ = compute_p_();
+ mln_postcondition(this->is_valid());
+ return *this;
}
- template <typename D>
- inline
- mln_coord(D)
- dpoints_bkd_piter<D>::operator[](unsigned i) const
- {
- mln_precondition(is_valid());
-
- // below we test that no update is required
- // meaning that p_ref_ has not moved or that
- // the user has explicitly called update()
- mln_precondition(p_ref_ + dps_[i_] == p_);
- // FIXME: Explain this issue in the class documentation...
-
- return p_[i];
- }
-
-
# endif // ! MLN_INCLUDE_ONLY
} // end of namespace mln
-#endif // ! MLN_CORE_DPOINTS_PITER_HH
+#endif // ! MLN_CORE_DPSITES_PITER_HH
Index: mln/core/neighb2d.hh
--- mln/core/neighb2d.hh (revision 2014)
+++ mln/core/neighb2d.hh (working copy)
@@ -45,7 +45,7 @@
/*! \brief Type alias for a neighborhood defined on the 2D square
* grid with integer coordinates.
*/
- typedef neighb_<dpoint2d> neighb2d;
+ typedef neighb<dpoint2d> neighb2d;
/*! \brief 4-connectivity neighborhood on the 2D grid.
Index: mln/core/p_array.hh
--- mln/core/p_array.hh (revision 2014)
+++ mln/core/p_array.hh (working copy)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007 EPITA Research and Development Laboratory
+// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -61,6 +61,11 @@
public:
+ // This associated type is important to know that this particular
+ // pseudo site knows the site set it refers to.
+ typedef p_array<P> target_t;
+
+
// As a Proxy:
const P& unproxy() const;
@@ -79,16 +84,23 @@
int index() const;
- int& index();
+ void change_index(int i);
+ void inc_index();
+ void dec_index();
const p_array<P>* target() const;
const p_array<P>*& target();
+ bool is_valid() const;
+
private:
const p_array<P>* arr_;
int i_;
+ mutable P p_;
+
+ void update_p_() const;
};
@@ -150,7 +162,9 @@
/// Test is \p p belongs to this site set.
bool has(const psite& p) const;
+ /// Test is index \p i belongs to this site set.
// FIXME: Add an overload "has(index)".
+ bool has_index(int i) const;
/// Change site \p p into \p new_p.
void change(const psite& p, const P& new_p);
@@ -227,6 +241,14 @@
template <typename P>
inline
+ bool
+ p_array<P>::has_index(int i) const
+ {
+ return i >= 0 && i < int(vect_.size());
+ }
+
+ template <typename P>
+ inline
std::size_t
p_array<P>::nsites() const
{
@@ -303,6 +325,7 @@
vect_[p.index()] = new_p;
}
+
// p_array_psite<P>
template <typename P>
@@ -315,10 +338,21 @@
template <typename P>
inline
+ void
+ p_array_psite<P>::update_p_() const
+ {
+ if (arr_ == 0 || ! arr_->has_index(i_))
+ return;
+ p_ = (*arr_)[i_];
+ }
+
+ template <typename P>
+ inline
p_array_psite<P>::p_array_psite(const p_array<P>& arr, int i)
: arr_(&arr),
i_(i)
{
+ update_p_();
}
template <typename P>
@@ -341,10 +375,29 @@
template <typename P>
inline
- int&
- p_array_psite<P>::index()
+ void
+ p_array_psite<P>::change_index(int i)
{
- return i_;
+ i_ = i;
+ update_p_();
+ }
+
+ template <typename P>
+ inline
+ void
+ p_array_psite<P>::dec_index()
+ {
+ --i_;
+ update_p_();
+ }
+
+ template <typename P>
+ inline
+ void
+ p_array_psite<P>::inc_index()
+ {
+ ++i_;
+ update_p_();
}
template <typename P>
@@ -369,7 +422,8 @@
p_array_psite<P>::unproxy() const
{
mln_precondition(arr_ != 0);
- return (*arr_)[i_];
+ update_p_();
+ return p_;
}
Index: mln/core/concept/pseudo_site.hh
--- mln/core/concept/pseudo_site.hh (revision 2014)
+++ mln/core/concept/pseudo_site.hh (working copy)
@@ -64,12 +64,30 @@
{
typedef Pseudo_Site<void> category;
+ // When a pseudo site features this associated type...
+ // typedef target_t;
+
+ // ...then it also features the method:
+ // const target_t* target();
protected:
Pseudo_Site();
};
+ namespace if_possible
+ {
+ // Nota: This procedure is used in internal::site_iterator_base.
+
+ template <typename P>
+ void change_target(Pseudo_Site<P>& p, const typename P::target_t& new_target);
+
+ template <typename O, typename T>
+ void change_target(Object<O>&, const T&);
+
+ } // end of namespace mln::if_possible
+
+
# ifndef MLN_INCLUDE_ONLY
template <typename E>
@@ -78,6 +96,23 @@
// FIXME
}
+ namespace if_possible
+ {
+
+ template <typename P>
+ void change_target(Pseudo_Site<P>& p, const typename P::target_t& new_target)
+ {
+ exact(p).target() = & new_target;
+ }
+
+ template <typename O, typename D>
+ void change_target(Object<O>&, const D&)
+ {
+ // No-op.
+ }
+
+ } // end of namespace mln::if_possible
+
# endif // ! MLN_INCLUDE_ONLY
} // end of namespace mln
Index: mln/core/concept/site_iterator.hh
--- mln/core/concept/site_iterator.hh (revision 2014)
+++ mln/core/concept/site_iterator.hh (working copy)
@@ -77,9 +77,8 @@
void invalidate();
void start();
- /// Change of site set target.
- template <typename T>
- void change_target(const T& the);
+ // Defined in site_iterator_base:
+ // void change_target(s);
protected:
Site_Iterator();
@@ -94,7 +93,7 @@
void
Site_Iterator<E>::next()
{
- mln_precondition(exact(this)->is_valid());
+ mln_precondition(is_valid());
exact(this)->next_();
}
@@ -117,6 +116,7 @@
if (exact(this)->target_() == 0)
return; // No-op.
exact(this)->invalidate_();
+ mln_postcondition(is_valid() == false);
}
template <typename E>
@@ -129,16 +129,6 @@
}
template <typename E>
- template <typename T>
- inline
- void
- Site_Iterator<E>::change_target(const T& the)
- {
- exact(this)->target_() = & the;
- exact(this)->invalidate_();
- }
-
- template <typename E>
inline
Site_Iterator<E>::Site_Iterator()
{
@@ -152,6 +142,8 @@
m3 = 0;
void (E::*m4)() = & E::next_;
m4 = 0;
+ bool m5 = (& E::change_target) == (& E::change_target);
+ m5 = 0;
}
# endif // ! MLN_INCLUDE_ONLY
Index: mln/core/concept/site_set.hh
--- mln/core/concept/site_set.hh (revision 2014)
+++ mln/core/concept/site_set.hh (working copy)
@@ -81,6 +81,9 @@
bool has(const psite& p) const;
*/
+ template <typename S>
+ E& insert_all(const Site_Set<S>& other);
+
protected:
Site_Set();
};
@@ -167,6 +170,18 @@
}
+ template <typename E>
+ template <typename S>
+ inline
+ E& Site_Set<E>::insert_all(const Site_Set<S>& other)
+ {
+ E& self = exact(*this);
+ mln_fwd_piter(S) p(exact(other));
+ for_all(p)
+ self.insert(p);
+ return self;
+ }
+
// operators
Index: mln/core/image2d.hh
--- mln/core/image2d.hh (revision 2014)
+++ mln/core/image2d.hh (working copy)
@@ -39,7 +39,7 @@
# include <mln/border/thickness.hh>
# include <mln/value/set.hh>
# include <mln/fun/i2v/all_to.hh>
-# include <mln/core/line_piter.hh>
+// # include <mln/core/line_piter.hh> // FIXME
// FIXME:
@@ -122,7 +122,11 @@
template <typename T>
struct image2d : public internal::image_primary_< box2d, image2d<T> >
{
+ typedef point2d point; // FIXME: HOT: to be removed.
+
+
// Warning: just to make effective types appear in Doxygen:
+
typedef box2d pset;
typedef point2d psite;
@@ -132,7 +136,6 @@
typedef mln_fwd_piter(box2d) fwd_piter;
typedef mln_bkd_piter(box2d) bkd_piter;
- typedef line_piter_<point2d> line_piter;
// End of warning.
@@ -550,7 +553,7 @@
# include <mln/core/trait/pixter.hh>
# include <mln/core/dpoints_pixter.hh>
# include <mln/core/pixter2d.hh>
-# include <mln/core/w_window.hh>
+// # include <mln/core/w_window.hh>
namespace mln
Index: mln/level/fill.hh
--- mln/level/fill.hh (revision 2014)
+++ mln/level/fill.hh (working copy)
@@ -164,7 +164,8 @@
{
trace::entering("level::fill");
- mlc_is(mln_trait_image_io(I), trait::image::io::write)::check(); // FIXME: Only the upcoming general facade!!!
+ mlc_is(mln_trait_image_value_io(I),
+ trait::image::value_io::read_write)::check(); // FIXME: Only the upcoming general facade!!!
mln_precondition(exact(ima).has_data());
impl::fill_with_value(mln_trait_image_speed(I)(), exact(ima),
value);
Index: mln/geom/max_col.hh
--- mln/geom/max_col.hh (revision 2014)
+++ mln/geom/max_col.hh (working copy)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007 EPITA Research and Development Laboratory
+// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -44,7 +44,7 @@
/// Give the maximum column of an image.
template <typename I>
- mln_coord(I) max_col(const Image<I>& ima);
+ mln_deduce(I, site, coord) max_col(const Image<I>& ima);
/// Give the maximum col of an box 2d or 3d.
template <typename B>
@@ -54,7 +54,7 @@
template <typename I>
inline
- mln_coord(I) max_col(const Image<I>& ima)
+ mln_deduce(I, site, coord) max_col(const Image<I>& ima)
{
mln_precondition(exact(ima).has_data());
return exact(ima).bbox().pmax().col();
Index: mln/geom/min_row.hh
--- mln/geom/min_row.hh (revision 2014)
+++ mln/geom/min_row.hh (working copy)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007 EPITA Research and Development Laboratory
+// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -47,7 +47,7 @@
/// Give the minimum row of an image.
template <typename I>
- mln_coord(I) min_row(const Image<I>& ima);
+ mln_deduce(I, site, coord) min_row(const Image<I>& ima);
/// Give the minimum row of an box 2d or 3d.
template <typename B>
@@ -58,7 +58,7 @@
template <typename I>
inline
- mln_coord(I) min_row(const Image<I>& ima)
+ mln_deduce(I, site, coord) min_row(const Image<I>& ima)
{
mln_precondition(exact(ima).has_data());
return exact(ima).bbox().pmin().row();
1
0
12 Jun '08
https://svn.lrde.epita.fr/svn/oln/trunk/milena/sandbox
Index: ChangeLog
from Ugo Jardonnet <jardonnet(a)lrde.epita.fr>
Sandox: ICP: Make it save images of every step of the registration.
* jardonnet/test/icp_ref.cc,
* jardonnet/test/icp.cc: Cleanup output image.
* jardonnet/test/Makefile: Remove gprof option.
* jardonnet/registration/save.hh: Add proper saving.
* jardonnet/registration/icp_ref.hh: Add step loggin.
Add images for test and slides.
* jardonnet/test/img/x10.pbm,
* jardonnet/test/img/x11.pbm,
* jardonnet/test/img/c10.pbm,
* jardonnet/test/img/c11.pbm: New test images.
registration/icp_ref.hh | 15 ++++++++---
registration/save.hh | 65
++++++++++++++++++++++++++++++++++++++----------
registration/tools.hh | 8 +++++
test/Makefile | 2 -
test/icp.cc | 10 ++++---
test/icp_ref.cc | 7 ++---
6 files changed, 82 insertions(+), 25 deletions(-)
Index: jardonnet/test/icp_ref.cc
--- jardonnet/test/icp_ref.cc (revision 2013)
+++ jardonnet/test/icp_ref.cc (working copy)
@@ -82,17 +82,18 @@
qk.apply_on(c, c, c.npoints());
image2d<value::rgb8> output(convert::to_box2d(working_box), 1);
+ level::fill(output, literal::white);
//to 2d : projection (FIXME:if 3d)
- for (size_t i = 0; i < c.npoints(); i++)
+ for (unsigned i = 0; i < c.npoints(); i++)
{
point2d p(c[i][0], c[i][1]);
if (output.has(p))
- output(p) = literal::white;
+ output(p) = literal::black;
}
//ref image
- for (size_t i = 0; i < x.npoints(); i++)
+ for (unsigned i = 0; i < x.npoints(); i++)
{
point2d px(x[i][0], x[i][1]);
if (output.has(px))
Index: jardonnet/test/icp.cc
--- jardonnet/test/icp.cc (revision 2013)
+++ jardonnet/test/icp.cc (working copy)
@@ -63,10 +63,6 @@
qk.apply_on(c, c, c.npoints());
- //init output image
- image2d<value::rgb8> output(convert::to_box2d(working_box), 0);
- level::fill(output, literal::white);
-
float stddev, mean;
registration::mean_stddev(c, map, mean, stddev);
@@ -84,6 +80,12 @@
quat7<3> fqk = registration::final_qk(c, map, 2*stddev);
fqk.apply_on(c, c, c.npoints());
+
+ //init output image
+ image2d<value::rgb8> output(convert::to_box2d(working_box), 0);
+ level::fill(output, literal::white);
+
+
//print x
for (size_t i = 0; i < x.npoints(); i++)
{
Index: jardonnet/test/img/x10.pbm
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes on: jardonnet/test/img/x10.pbm
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Index: jardonnet/test/img/x11.pbm
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes on: jardonnet/test/img/x11.pbm
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Index: jardonnet/test/img/c10.pbm
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes on: jardonnet/test/img/c10.pbm
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Index: jardonnet/test/img/c11.pbm
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes on: jardonnet/test/img/c11.pbm
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Index: jardonnet/test/Makefile
--- jardonnet/test/Makefile (revision 2013)
+++ jardonnet/test/Makefile (working copy)
@@ -23,7 +23,7 @@
g++ icp_ref.cc -I../../.. -g -o 'icp_refD'
icp_ref: icp_ref.cc ../registration/icp_ref.hh +depend
- g++ icp_ref.cc -I../../.. -pg -O3 -DNDEBUG -o 'icp_ref'
+ g++ icp_ref.cc -I../../.. -O3 -DNDEBUG -o 'icp_ref'
icp.o:
g++ -c icp.cc -I../../.. -O3 -DNDEBUG
Index: jardonnet/registration/save.hh
--- jardonnet/registration/save.hh (revision 2013)
+++ jardonnet/registration/save.hh (working copy)
@@ -1,37 +1,76 @@
#ifndef MLN_REGISTRATION_SAVE_HH
# define MLN_REGISTRATION_SAVE_HH
+# include <mln/convert/to_image.hh>
+# include <mln/io/ppm/save.hh>
+# include <mln/io/pbm/save.hh>
#include <string>
+# include "quat7.hh"
+# include "tools.hh"
+
namespace mln
{
+ namespace io
+ {
+ namespace pbm
+ {
+ template <typename P>
+ void save(const p_array<P>& a, const std::string& filename)
+ {
+ mln_precondition(P::dim == 2);
+
+ image2d out = convert::to_image(a);
+ save(out, filename);
+ }
+ }
+ }
+
+
namespace registration
{
template <typename P>
- void save_(const p_array<P>& Ck, int l)
+ void save_(const quat7<3>& qk,
+ const p_array<P>& c,
+ const p_array<P>& x,
+ int every)
{
static int id = 0;
+ static int i = 0;
+
+ if (++i % every != 0)
+ return;
- using namespace std;
+ //build ck: apply transform
+ p_array<P> ck(c);
+ qk.apply_on(c, ck, c.npoints());
- //FIXME: Should use Ck box but Ck.bbox() is not correct for c_length
- image2d<bool> img(box2d(500,800), 0);
- for (size_t i = 0; i < l; i++)
+ const box_<P> working_box = enlarge(bigger(ck.bbox(),x.bbox()),100);
+ image2d<value::rgb8> out(convert::to_box2d(working_box), 1);
+ level::fill(out, literal::white);
+
+ //x in green
+ for (unsigned i = 0; i < ck.npoints(); i++)
{
- point2d p = convert::to_point2d(Ck[i]);
- if (img.has(p))
- img(p) = true;
+ point2d p(ck[i][0], ck[i][1]);
+ if (out.has(p))
+ out(p) = literal::green;
}
- //FIXME: Good but put point after c_length
- //image2d<bool> img = convert::to_image2d(Ck);
+ //x in black
+ for (unsigned i = 0; i < x.npoints(); i++)
+ {
+ point2d p(x[i][0], x[i][1]);
+ if (out.has(p))
+ out(p) = literal::black;
+ }
+ //save
std::stringstream oss;
- oss << "i_" << id++ << ".pbm";
- io::pbm::save(img, oss.str());
-
+ oss << "step_" << id++ << ".ppm";
+ io::ppm::save(out, oss.str());
}
}
Index: jardonnet/registration/tools.hh
--- jardonnet/registration/tools.hh (revision 2013)
+++ jardonnet/registration/tools.hh (working copy)
@@ -12,6 +12,14 @@
namespace mln
{
+ namespace registration
+ {
+
+
+
+ }
+
+
template <typename P>
void shuffle(p_array<P>& a)
{
Index: jardonnet/registration/icp_ref.hh
--- jardonnet/registration/icp_ref.hh (revision 2013)
+++ jardonnet/registration/icp_ref.hh (working copy)
@@ -57,9 +57,13 @@
# include "save.hh"
+
+
namespace mln
{
+
+
namespace registration
{
@@ -89,6 +93,7 @@
const M& map,
quat7<P::dim>& qk,
const size_t c_length,
+ const p_array<P>& X,
const float epsilon = 1e-3)
{
trace::entering("registration::impl::icp_");
@@ -131,7 +136,9 @@
e_k = rms(C, map, c_length, buf_qk[1], buf_qk[1]);
#ifndef NDEBUG
- //plot file
+ //save file
+ save_(qk,C,X,5);
+ //print info
std::cout << k << '\t' << (e_k >= d_k ? ' ' : '-') << '\t'
<< e_k << '\t' << d_k << '\t'
<< ((qk - buf_qk[1]).sqr_norm() / qk.sqr_norm())
<< '\t'
<< std::endl;
@@ -139,8 +146,8 @@
pts += c_length;
#endif
k++;
- } while (e_k >= d_k && d_k_1 - d_k > epsilon);
- // FIXME : test (e_k >= d_k) seems to be a bad idea.
+ } while (d_k_1 - d_k > epsilon);
+ // FIXME : test (e_k >= d_k) but seems to be a bad idea.
trace::exiting("registration::impl::icp_");
}
@@ -188,7 +195,7 @@
size_t l = cloud.npoints() / std::pow(q, e);
l = (l<1) ? 1 : l;
- impl::icp_(cloud, map, qk, l, 1e-3);
+ impl::icp_(cloud, map, qk, l, x, 1e-3);
#ifndef NDEBUG
{
1
0
12 Jun '08
https://svn.lrde.epita.fr/svn/oln/branches/cleanup-2008/milena
Index: ChangeLog
from Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
Revamp design of Neighborhood and Window.
Add a new utility set whose behavior is transparent for the client
(conversely to util::lazy_set_) and memory saving (conversely to
internal::set_of_).
* mln/util/set.hh: New.
* tests/util/set.cc: New.
Revamp design of Neighborhood and Window.
* doc/tutorial/examples/image2d.cc: Use window2d.
* mln/core/point.hh (dpsite): New associated type.
* mln/core/window.hh: Update inheritance.
(is_centered): Move here from dpoints_base_; such a method
is not featured by neighborhoods so it cannot be factored in
window_base.
(fwd_qiter, bkd_qiter, insert): Move in impl super class.
(operator<<): Split decl and def; update.
(window): Now rely on...
* mln/core/internal/basic_window_impl.hh: ...this new class.
(set_of_): Replace inheritance by delegation to util::set.
(fwd_qiter, bkd_qiter, insert): New factor defs; they were in
window class. Now delegate code to insert_.
(insert_): New default impl; such method can be overridden.
* mln/core/internal/window_base.hh: New; for consistency
purpose.
* mln/core/dpoint.hh (psite, site): New.
* mln/core/concept/neighborhood.hh: Layout.
(Neighborhood): Change inheritance to Window.
(dpoint, point): Remove cause not general.
* mln/core/concept/window.hh (point, dpoint): Rename as...
(psite, dpsite): ...these.
(site): New associated type.
(is_empty, is_centered, is_symmetric, sym): Remove; not general.
* mln/core/concept/doc/window.hh: Update.
doc/tutorial/examples/image2d.cc | 8
mln/core/concept/doc/window.hh | 25 --
mln/core/concept/neighborhood.hh | 11 -
mln/core/concept/window.hh | 31 ---
mln/core/dpoint.hh | 6
mln/core/internal/basic_window_impl.hh | 162 ++++++++++++----
mln/core/internal/window_base.hh | 83 ++++++++
mln/core/point.hh | 3
mln/core/window.hh | 102 ++--------
mln/util/set.hh | 316 +++++++++++++--------------------
tests/util/set.cc | 51 +++++
11 files changed, 439 insertions(+), 359 deletions(-)
Index: tests/util/set.cc
--- tests/util/set.cc (revision 0)
+++ tests/util/set.cc (revision 0)
@@ -0,0 +1,51 @@
+// Copyright (C) 2008 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+/*!
+ * \file tests/util/set.cc
+ *
+ * \brief test of mln::util::set
+ *
+ */
+
+#include <mln/util/set.hh>
+
+int main ()
+{
+ using namespace mln;
+ util::set<int> s;
+ s.insert(1).insert(6).insert(6).insert(4);
+ mln_assertion(s.nelements() == 3);
+ s.remove(6);
+ mln_assertion(s.nelements() == 2);
+ mln_assertion(! s.has(6)); // not frozen
+ s.insert(6);
+ mln_assertion(s[2] == 6);
+ mln_assertion(s.has(6)); // frozen
+ s.clear();
+ mln_assertion(s.is_empty());
+}
Index: doc/tutorial/examples/image2d.cc
--- doc/tutorial/examples/image2d.cc (revision 2012)
+++ doc/tutorial/examples/image2d.cc (working copy)
@@ -1,4 +1,5 @@
# include <mln/core/image2d.hh>
+# include <mln/core/window2d.hh>
int main()
@@ -7,4 +8,11 @@
image2d<char> ima(2, 3);
mln_invariant(ima.nsites() == 6);
+
+ window2d win;
+ win
+ .insert(-1, 0)
+ .insert(0, -1)
+ .insert(-1,-1);
+ std::cout << win << std::endl;
}
Index: mln/core/point.hh
--- mln/core/point.hh (revision 2012)
+++ mln/core/point.hh (working copy)
@@ -93,6 +93,9 @@
/// Dpoint associated type.
typedef dpoint_<M,C> dpoint;
+ /// DPsite associated type.
+ typedef dpoint_<M,C> dpsite;
+
/// Coordinate associated type.
typedef C coord;
Index: mln/core/window.hh
--- mln/core/window.hh (revision 2012)
+++ mln/core/window.hh (working copy)
@@ -36,9 +36,8 @@
* point_, neighb_, etc.
*/
-# include <mln/core/concept/window.hh>
-# include <mln/core/concept/point_site.hh>
-# include <mln/core/internal/dpoints_base.hh>
+# include <mln/core/internal/window_base.hh>
+# include <mln/core/internal/basic_window_impl.hh>
# include <mln/core/dpoint.hh>
# include <mln/core/box.hh>
@@ -50,34 +49,17 @@
namespace mln
{
- // fwd decls
- template <typename D> class dpoints_fwd_piter;
- template <typename D> class dpoints_bkd_piter;
-
-
/*! \brief Generic window class.
*
* This type of window is just like a set of delta-points. The
* parameter is \c D, type of delta-point.
*/
template <typename D>
- class window : public Window< window<D> >,
- public internal::dpoints_base_<D, window<D> >
+ class window : public internal::window_base< D, window<D> >,
+ public internal::basic_window_impl< D, window<D> >
{
- typedef internal::dpoints_base_<D, window<D> > super_;
public:
- /*! \brief Site_Iterator type to browse the points of a generic window
- * w.r.t. the ordering of delta-points.
- */
- typedef dpoints_fwd_piter<D> fwd_qiter;
-
- /*! \brief Site_Iterator type to browse the points of a generic window
- * w.r.t. the reverse ordering of delta-points.
- */
- typedef dpoints_bkd_piter<D> bkd_qiter;
-
-
/*! \brief Constructor without argument.
*
* The constructed window is empty.
@@ -85,24 +67,16 @@
window();
+ /*! \brief Test if the window is centered.
+ *
+ * \return True if the delta-point 0 belongs to the window.
+ */
+ bool is_centered() const;
+
/*! \brief Test if the window is symmetric.
*/
bool is_symmetric() const;
- /// Insert a delta-point \p dp.
- window<D>& insert(const D& dp);
-
- /// \{ Insertion of a delta-point with different numbers of
- /// arguments (coordinates) w.r.t. the dimension.
- window<D>& insert(const mln_coord(D)& dind); // For 1D.
-
- window<D>& insert(const mln_coord(D)& drow,
- const mln_coord(D)& dcol); // For 2D.
-
- window<D>& insert(const mln_coord(D)& dsli,
- const mln_coord(D)& drow,
- const mln_coord(D)& dcol); // For 3D.
- /// \}
/// Apply a central symmetry to the target window.
window<D>& sym();
@@ -113,15 +87,9 @@
};
- // FIXME: Move code at EOF + doc.
+ // FIXME: Doc!
template <typename D>
- std::ostream& operator<<(std::ostream& ostr, const window<D>& win)
- {
- // FIXME
- for (unsigned i = 0; i < win.ndpoints(); ++i)
- ostr << win.dp(i);
- return ostr;
- }
+ std::ostream& operator<<(std::ostream& ostr, const window<D>& win);
@@ -134,7 +102,7 @@
window<D>::window()
{
// FIXME HERE: Was: mln::metal::is_a<D, Dpoint>::check();
- mln::metal::is_a<D, Delta_Point_Site>::check();
+ // mln::metal::is_a<D, Delta_Point_Site>::check();
}
template <typename D>
@@ -146,42 +114,10 @@
template <typename D>
inline
- window<D>&
- window<D>::insert(const D& dp)
+ bool window<D>::is_centered() const
{
- mln_precondition(! has(dp));
- this->super_::insert(dp);
- return *this;
- }
-
- template <typename D>
- inline
- window<D>&
- window<D>::insert(const mln_coord(D)& dind)
- {
- D dp(dind);
- mln_precondition(! has(dp));
- return this->insert(dp);
- }
-
- template <typename D>
- inline
- window<D>&
- window<D>::insert(const mln_coord(D)& drow, const mln_coord(D)& dcol)
- {
- D dp(drow, dcol);
- mln_precondition(! has(dp));
- return this->insert(dp);
- }
-
- template <typename D>
- inline
- window<D>&
- window<D>::insert(const mln_coord(D)& dsli, const mln_coord(D)& drow, const mln_coord(D)& dcol)
- {
- D dp(dsli, drow, dcol);
- mln_precondition(! has(dp));
- return this->insert(dp);
+ static const D origin = all_to(0);
+ return this->dps_.has(origin); // FIXME: Use literal::origin.
}
template <typename D>
@@ -197,6 +133,12 @@
return *this;
}
+ template <typename D>
+ std::ostream& operator<<(std::ostream& ostr, const window<D>& win)
+ {
+ return ostr << win.dps_hook();
+ }
+
# endif // ! MLN_INCLUDE_ONLY
} // end of namespace mln
Index: mln/core/internal/basic_window_impl.hh
--- mln/core/internal/basic_window_impl.hh (revision 2012)
+++ mln/core/internal/basic_window_impl.hh (working copy)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007 EPITA Research and Development Laboratory
+// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -25,15 +25,15 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef MLN_CORE_INTERNAL_DPOINTS_BASE_HH
-# define MLN_CORE_INTERNAL_DPOINTS_BASE_HH
+#ifndef MLN_CORE_INTERNAL_BASIC_WINDOW_IMPL_HH
+# define MLN_CORE_INTERNAL_BASIC_WINDOW_IMPL_HH
-/*! \file mln/core/internal/dpoints_base.hh
+/*! \file mln/core/internal/basic_window_impl.hh
*
* \brief Definition of a base class for classes based on a set of dpoints.
*/
-# include <mln/core/internal/set_of.hh>
+# include <mln/util/set.hh>
# include <mln/fun/i2v/all_to.hh>
# include <mln/norm/linfty.hh>
@@ -41,6 +41,11 @@
namespace mln
{
+ // Fwd decls.
+ template <typename D> class dpoints_fwd_piter;
+ template <typename D> class dpoints_bkd_piter;
+
+
namespace internal
{
@@ -48,23 +53,27 @@
*
*/
template <typename D, typename E>
- class dpoints_base_ : protected internal::set_of_<D>
+ class basic_window_impl
{
- typedef internal::set_of_<D> super_;
- public:
+ util::set<D> dps_;
- /// Point associated type.
- typedef mln_point(D) point;
+ public:
- /// Dpoint associated type.
- typedef D dpoint;
+ /*! \brief Site_Iterator type to browse the points of a basic window
+ * whatever the ordering of delta-points.
+ */
+ typedef dpoints_fwd_piter<D> qiter;
+ /*! \brief Site_Iterator type to browse the points of a basic window
+ * w.r.t. the ordering of delta-points.
+ */
+ typedef dpoints_fwd_piter<D> fwd_qiter;
- /*! \brief Test if the window is centered.
- *
- * \return True if the delta-point 0 belongs to the window.
+ /*! \brief Site_Iterator type to browse the points of a basic window
+ * w.r.t. the reverse ordering of delta-points.
*/
- bool is_centered() const;
+ typedef dpoints_bkd_piter<D> bkd_qiter;
+
/*! \brief Test if the window is empty (null size; no delta-point).
*/
@@ -84,11 +93,36 @@
// Give the \p i-th delta-point.
const D& dp(unsigned i) const;
+
// Give the vector of delta-points.
- const std::vector<D>& vect() const;
+ const std::vector<D>& std_vector() const;
+
+
+ /// Insert a delta-point \p dp.
+ E& insert(const D& dp);
+
+ /// \{ Insertion of a delta-point with different numbers of
+ /// arguments (coordinates) w.r.t. the dimension.
+ E& insert(const mln_coord(D)& dind); // For 1D.
+
+ E& insert(const mln_coord(D)& drow,
+ const mln_coord(D)& dcol); // For 2D.
+
+ E& insert(const mln_coord(D)& dsli,
+ const mln_coord(D)& drow,
+ const mln_coord(D)& dcol); // For 3D.
+ /// \}
+
+
+ const util::set<D>& dps_hook() const;
protected:
- dpoints_base_();
+
+ basic_window_impl();
+
+ void insert_(const D& dp); // The only routine to effectively insert a dp.
+ // This is a default implementation. This routine can be
+ // overidden in sub-classes.
};
@@ -97,29 +131,22 @@
template <typename D, typename E>
inline
- dpoints_base_<D,E>::dpoints_base_()
+ basic_window_impl<D,E>::basic_window_impl()
{
}
template <typename D, typename E>
inline
- bool dpoints_base_<D,E>::is_centered() const
+ bool basic_window_impl<D,E>::is_empty() const
{
- static const D origin = all_to(0);
- return this->super_::has(origin);
+ return dps_.is_empty();
}
template <typename D, typename E>
inline
- bool dpoints_base_<D,E>::is_empty() const
- {
- return this->super_::is_empty();
- }
-
- template <typename D, typename E>
- inline
- unsigned dpoints_base_<D,E>::delta() const
+ unsigned basic_window_impl<D,E>::delta() const
{
+ // FIXME: Is-it correct?
unsigned d = 0;
const unsigned n = ndpoints();
for (unsigned i = 0; i < n; ++i)
@@ -134,34 +161,91 @@
template <typename D, typename E>
inline
unsigned
- dpoints_base_<D,E>::ndpoints() const
+ basic_window_impl<D,E>::ndpoints() const
{
- return this->super_::nelements();
+ return dps_.nelements();
}
template <typename D, typename E>
inline
const D&
- dpoints_base_<D,E>::dp(unsigned i) const
+ basic_window_impl<D,E>::dp(unsigned i) const
{
mln_precondition(i < ndpoints());
- return this->element(i);
+ return dps_[i];
}
template <typename D, typename E>
inline
const std::vector<D>&
- dpoints_base_<D,E>::vect() const
+ basic_window_impl<D,E>::vect() const
{
- return this->super_::vect();
+ return dps_.vect();
}
template <typename D, typename E>
inline
bool
- dpoints_base_<D,E>::has(const D& dp) const
+ basic_window_impl<D,E>::has(const D& dp) const
+ {
+ return dps_.has(dp);
+ }
+
+ template <typename D, typename E>
+ inline
+ E&
+ basic_window_impl<D,E>::insert(const D& dp)
+ {
+ E& self_ = internal::force_exact<E>(*this);
+ self_.insert_(dp);
+ return self_;
+ }
+
+ template <typename D, typename E>
+ inline
+ E&
+ basic_window_impl<D,E>::insert(const mln_coord(D)& dind)
+ {
+ D dp(dind);
+ return insert(dp);
+ }
+
+ template <typename D, typename E>
+ inline
+ E&
+ basic_window_impl<D,E>::insert(const mln_coord(D)& drow,
+ const mln_coord(D)& dcol)
+ {
+ D dp(drow, dcol);
+ return insert(dp);
+ }
+
+ template <typename D, typename E>
+ inline
+ E&
+ basic_window_impl<D,E>::insert(const mln_coord(D)& dsli,
+ const mln_coord(D)& drow,
+ const mln_coord(D)& dcol)
+ {
+ D dp(dsli, drow, dcol);
+ return insert(dp);
+ }
+
+ template <typename D, typename E>
+ inline
+ void
+ basic_window_impl<D,E>::insert_(const D& dp)
+ {
+ mln_precondition(! has(dp));
+ dps_.insert(dp);
+ }
+
+ template <typename D, typename E>
+ inline
+ const util::set<D>&
+ basic_window_impl<D,E>::dps_hook() const
{
- return this->super_::has(dp);
+ return dps_;
}
# endif // ! MLN_INCLUDE_ONLY
@@ -171,4 +255,4 @@
} // end of namespace mln
-#endif // ! MLN_CORE_INTERNAL_DPOINTS_BASE_HH
+#endif // ! MLN_CORE_INTERNAL_BASIC_WINDOW_IMPLHH
Index: mln/core/internal/window_base.hh
--- mln/core/internal/window_base.hh (revision 0)
+++ mln/core/internal/window_base.hh (revision 0)
@@ -0,0 +1,83 @@
+// Copyright (C) 2008 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef MLN_CORE_INTERNAL_WINDOW_BASE_HH
+# define MLN_CORE_INTERNAL_WINDOW_BASE_HH
+
+/*! \file mln/core/internal/window_base.hh
+ *
+ * \brief Definition of a base class for site set classes.
+ */
+
+# include <mln/core/concept/window.hh>
+
+
+namespace mln
+{
+
+ namespace internal
+ {
+
+
+ /*! \internal A base class for window classes.
+ *
+ * \p D is a dpsite type.
+ */
+ template <typename D, typename E>
+ struct window_base : public Window<E>
+ {
+
+ /// DPsite associated type.
+ typedef D dpsite;
+
+ /// Psite associated type.
+ typedef mln_psite(D) psite;
+
+ /// Site associated type.
+ typedef mln_site(D) site;
+
+ protected:
+ window_base();
+ };
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename S, typename E>
+ inline
+ window_base<S,E>::window_base()
+ {
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::internal
+
+} // end of namespace mln
+
+
+#endif // ! MLN_CORE_INTERNAL_WINDOW_BASE_HH
Index: mln/core/dpoint.hh
--- mln/core/dpoint.hh (revision 2012)
+++ mln/core/dpoint.hh (working copy)
@@ -72,6 +72,12 @@
/// Point associated type.
typedef point_<M,C> point;
+ /// Psite associated type.
+ typedef point_<M,C> psite;
+
+ /// Site associated type.
+ typedef point_<M,C> site;
+
/// Coordinate associated type.
typedef C coord;
Index: mln/core/concept/neighborhood.hh
--- mln/core/concept/neighborhood.hh (revision 2012)
+++ mln/core/concept/neighborhood.hh (working copy)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007 EPITA Research and Development Laboratory
+// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -32,7 +32,7 @@
* \brief Definition of the concept of mln::Neighborhood.
*/
-# include <mln/core/concept/object.hh>
+# include <mln/core/concept/window.hh>
namespace mln
@@ -55,7 +55,7 @@
* class contents.
*/
template <typename E>
- struct Neighborhood : public Object<E>
+ struct Neighborhood : public Window<E>
{
typedef Neighborhood<void> category;
@@ -63,9 +63,6 @@
typedef niter;
typedef fwd_niter;
typedef bkd_niter;
-
- typedef dpoint;
- typedef point;
*/
protected:
@@ -82,8 +79,6 @@
typedef mln_niter(E) niter;
typedef mln_fwd_niter(E) fwd_niter;
typedef mln_bkd_niter(E) bkd_niter;
- typedef mln_dpoint(E) dpoint;
- typedef mln_point(E) point;
}
# endif // ! MLN_INCLUDE_ONLY
Index: mln/core/concept/window.hh
--- mln/core/concept/window.hh (revision 2012)
+++ mln/core/concept/window.hh (working copy)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007 EPITA Research and Development Laboratory
+// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -61,20 +61,13 @@
typedef Window<void> category;
/*
- typedef point;
- typedef dpoint;
+ typedef site;
+ typedef psite;
+ typedef dpsite;
typedef qiter;
typedef fwd_qiter;
typedef bkd_qiter;
-
- bool is_empty() const;
- bool is_centered() const;
- bool is_symmetric() const;
-
- unsigned delta() const;
-
- E& sym();
*/
protected:
@@ -99,23 +92,13 @@
inline
Window<E>::Window()
{
- typedef mln_point(E) point;
- typedef mln_dpoint(E) dpoint;
+ typedef mln_site(E) site;
+ typedef mln_psite(E) psite;
+ typedef mln_dpsite(E) dpsite;
typedef mln_qiter(E) qiter;
typedef mln_fwd_qiter(E) fwd_qiter;
typedef mln_bkd_qiter(E) bkd_qiter;
-
- bool (E::*m1)() const = & E::is_empty;
- m1 = 0;
- bool (E::*m2)() const = & E::is_centered;
- m2 = 0;
- bool (E::*m3)() const = & E::is_symmetric;
- m3 = 0;
- unsigned (E::*m4)() const = & E::delta;
- m4 = 0;
- E& (E::*m5)() = & E::sym;
- m5 = 0;
}
template <typename Wl, typename Wr>
Index: mln/core/concept/doc/window.hh
--- mln/core/concept/doc/window.hh (revision 2012)
+++ mln/core/concept/doc/window.hh (working copy)
@@ -59,31 +59,6 @@
* points in a backward way.
*/
typedef void bkd_qiter;
-
- /*! \brief Test if the window is empty.
- *
- * A window of null size is empty.
- */
- bool is_empty() const;
-
- /*! \brief Test if the window is centered.
- *
- * A window is centered is the origin belongs to the window.
- */
- bool is_centered() const;
-
- /*! \brief Test if the window is symmetric.
- */
- bool is_symmetric() const;
-
- /*! \brief Give the maximum coordinate gap between the window
- center and a window point.
- */
- unsigned delta() const;
-
- /*! \brief Apply a central symmetry to the target window.
- */
- E& sym();
};
} // end of namespace mln::doc
Index: mln/util/set.hh
--- mln/util/set.hh (revision 2012)
+++ mln/util/set.hh (working copy)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007 EPITA Research and Development Laboratory
+// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -25,20 +25,22 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef MLN_UTIL_LAZY_SET_HH
-# define MLN_UTIL_LAZY_SET_HH
+#ifndef MLN_UTIL_SET_HH
+# define MLN_UTIL_SET_HH
-/*! \file mln/util/lazy_set.hh
+/*! \file mln/util/set.hh
*
- * \brief Definition of mln::lazy_set_ for internal use only.
+ * \brief Definition of mln::util::set.
+ *
+ * \todo Clean code and test!
*/
# include <vector>
# include <set>
# include <iterator>
# include <algorithm>
+# include <iostream>
-# include <mln/core/internal/force_exact.hh>
# include <mln/core/contract.hh>
@@ -57,52 +59,72 @@
*
* Elements are stored by copy. Implementation is lazy.
*
- * \invariant \a v_.size() == s_.size()
+ * The set has two states: frozen or not. There is an automatic
+ * switch of state when the user modifies its contents (insert,
+ * remove, or clear) or access to its contents (op[i]).
*
- * The parameter \c E is the element type, which shall not be
+ * The parameter \c T is the element type, which shall not be
* const-qualified.
*
* \todo Add a remove method.
*/
- template <typename E>
- class lazy_set_
+ template <typename T>
+ class set
{
public:
- /// Type of the stored value.
- typedef E value;
+ /// Type of elements.
+ typedef T element;
+
/*! \brief Insert an element \p elt into the set.
*
* \param[in] elt The element to be inserted.
*
+ * \pre The set is not frozen.
+ *
* If \p elt is already in the set, this method is a no-op.
*
* \return The set itself after insertion.
*/
- lazy_set_<E>& insert(const E& elt);
+ set<T>& insert(const T& elt);
/*! \brief Remove an element \p elt into the set.
*
* \param[in] elt The element to be inserted.
*
+ * \pre The set is not frozen.
+ *
* If \p elt is already in the set, this method is a no-op.
*
* \return The set itself after suppression.
*/
- lazy_set_<E>& remove(const E& elt);
+ set<T>& remove(const T& elt);
- /*! \brief Return the i-th element of the set.
+ /*! \brief Empty the set.
*
- * \param[in] i Index of the element to retrieve.
+ * All elements contained in the set are destroyed so the set is
+ * emptied.
*
- * \pre i < nelements()
+ * \pre The set is not frozen.
*
- * The element is returned by reference and is constant.
+ * \post is_empty() == true
*/
- const E& element(unsigned i) const;
+ void clear();
+
+
+ /*! \brief Return the number of elements of the set.
+ */
+ unsigned nelements() const;
+
+
+ /*! \brief Test if the set is empty.
+ */
+ bool is_empty() const;
+
+
/*! \brief Return the i-th element of the set.
*
@@ -112,11 +134,7 @@
*
* The element is returned by reference and is constant.
*/
- const E& operator[](unsigned i) const;
-
- /*! \brief Return the number of elements of the set.
- */
- unsigned nelements() const;
+ const T& operator[](unsigned i) const;
/*! \brief Test if the object \p elt belongs to the set.
@@ -125,51 +143,23 @@
*
* \return True is \p elt is in the set.
*/
- bool has(const E& elt) const;
-
-
- /*! \brief Test if the set is empty.
- */
- bool is_empty() const;
-
-
- /*! \brief Make the set empty.
- *
- * All elements contained in the set are destroyed so the set is
- * emptied.
- * The lazy set can be cleared even if it is in const mode
- * and then it is set in non-const mode.
- *
- * \post is_empty() == true
- */
- void clear();
+ bool has(const T& elt) const;
/*! \brief Give access to the set elements.
*
* The complexity of this method is O(1).
*
+ * \post The set is frozen.
+ *
* \return An array (std::vector) of elements.
*/
- const std::vector<E>& vect() const;
+ const std::vector<T>& vect() const;
- /// Constructor without arguments.
- lazy_set_();
- /*! \brief Set the mode of the lazy_set
- *
- * The lazy set can have two modes :
- * - const : The lazy set is as light as a vector but you cannot
- * modify it
- * - non-const : The lazy set use a std::set to have lazy manipulation
- *
- * \param[in] mode True for const mode, false for non-const.
- *
- */
- void set_const_mode(bool mode);
+ /// Constructor without arguments.
+ set();
- /// Get the mode of the lazy set.
- bool get_mode() const;
private:
@@ -178,197 +168,157 @@
* This structure is only updated (if required) when elements
* are accessed.
*/
- mutable std::vector<E> v_;
+ mutable std::vector<T> v_;
/*! \brief Set of elements.
*
* This structure is always up-to-date w.r.t. the set contents.
*/
- std::set<E> s_;
+ mutable std::set<T> s_;
- /*! \brief Update \a v_ from \a s_.
- *
- * Make the vector contains the same element than the sorted set..
+ /*! \brief Freeze the contents of the set (update \a v_ from \a
+ * s_, then clear s_).
*/
- void update_() const;
+ void freeze_() const;
- /// Tell if \a v_ needs to be updated.
- mutable bool needs_update_;
+ /*! \brief Unfreeze the contents of the set.
+ */
+ void unfreeze_() const;
- /// Tell what the lazy set mode is.
- bool mode_;
+ /// Tell if the set is frozen.
+ mutable bool frozen_;
};
# ifndef MLN_INCLUDE_ONLY
- template <typename E>
+ template <typename T>
inline
- lazy_set_<E>::lazy_set_()
+ set<T>::set()
{
- needs_update_ = false;
- mode_ = false;
+ frozen_ = false;
}
- template <typename E>
+ template <typename T>
inline
- lazy_set_<E>&
- lazy_set_<E>::insert(const E& elt)
+ set<T>&
+ set<T>::insert(const T& elt)
{
- mln_assertion(!mode_);
+ if (frozen_) unfreeze_();
s_.insert(elt);
- if (needs_update_ == false)
- needs_update_ = true;
- return mln::internal::force_exact< lazy_set_<E> >(*this);
+ return *this;
}
- template <typename E>
+ template <typename T>
inline
- lazy_set_<E>&
- lazy_set_<E>::remove(const E& elt)
+ set<T>&
+ set<T>::remove(const T& elt)
{
- mln_assertion(!mode_);
- // FIXME : doesn't compile
- std::remove(s_.begin(), s_.end(), elt);
- if (needs_update_ == false)
- needs_update_ = true;
- return mln::internal::force_exact< lazy_set_<E> >(*this);
+ if (frozen_) unfreeze_();
+ s_.erase(elt);
+ return *this;
}
- template <typename E>
+ template <typename T>
inline
- const E&
- lazy_set_<E>::element(unsigned i) const
+ void
+ set<T>::clear()
{
- assert((!mode_ && i < s_.size())
- || i < v_.size());
- if (!mode_)
- if (needs_update_)
- update_();
- return v_[i];
+ if (frozen_)
+ {
+ mln_invariant(s_.empty());
+ v_.clear();
+ frozen_ = false;
}
-
- template <typename E>
- inline
- const E&
- lazy_set_<E>::operator[](unsigned i) const
+ else
{
- return this->element(i);
+ mln_invariant(v_.empty());
+ s_.clear();
+ }
+ mln_postcondition(is_empty());
}
- template <typename E>
+ template <typename T>
inline
unsigned
- lazy_set_<E>::nelements() const
+ set<T>::nelements() const
{
- if (!mode_)
- return s_.size();
- else
- return v_.size();
+ return frozen_ ? v_.size() : s_.size();
}
- template <typename E>
+ template <typename T>
inline
- bool
- lazy_set_<E>::has(const E& elt) const
+ const T&
+ set<T>::operator[](unsigned i) const
{
- if (!mode_)
- return s_.find(elt) != s_.end();
- else
- return v_.find(elt) != v_.end();
+ mln_precondition(i < nelements());
+ if (! frozen_) freeze_();
+ return v_[i];
}
- template <typename E>
+ template <typename T>
inline
bool
- lazy_set_<E>::is_empty() const
+ set<T>::has(const T& elt) const
{
- return nelements() == 0;
+ return frozen_
+ ? std::find(v_.begin(), v_.end(), elt) != v_.end()
+ : s_.find(elt) != s_.end();
}
- template <typename E>
+ template <typename T>
inline
- void
- lazy_set_<E>::clear()
+ bool
+ set<T>::is_empty() const
{
- v_.clear();
- s_.clear();
- needs_update_ = false;
- mode_ = false;
- mln_postcondition(is_empty());
+ return nelements() == 0;
}
- template <typename E>
+ template <typename T>
inline
- const std::vector<E>&
- lazy_set_<E>::vect() const
+ const std::vector<T>&
+ set<T>::vect() const
{
- if (!mode_)
- if (needs_update_)
- update_();
+ if (! frozen_) freeze_();
return v_;
}
- template <typename E>
+ template <typename T>
inline
void
- lazy_set_<E>::set_const_mode(bool mode)
- {
- if (mode != mode_)
+ set<T>::freeze_() const
{
- if (mode)
- {
- if (needs_update_)
- update_();
+ mln_precondition(frozen_ == false);
+ mln_invariant(v_.empty());
+ std::copy(s_.begin(), s_.end(), std::back_inserter(v_));
s_.clear();
- }
- else
- {
- mln_assertion(s_.size() == 0);
- for (typename std::vector<E>::iterator it = v_.begin();
- it != v_.end(); it++)
- s_.insert(*it);
- needs_update_ = false;
- }
- mode_ = mode;
- }
+ frozen_ = true;
}
- template <typename E>
- inline
- bool
- lazy_set_<E>::get_mode() const
- {
- return mode_;
- }
-
- template <typename E>
+ template <typename T>
inline
void
- lazy_set_<E>::update_() const
+ set<T>::unfreeze_() const
{
- mln_precondition(needs_update_ && !mode_);
+ mln_precondition(frozen_ == true);
+ mln_invariant(s_.empty());
+ s_.insert(v_.begin(), v_.end());
v_.clear();
- std::copy(s_.begin(), s_.end(), std::back_inserter(v_));
- // no s_.clear() here:
- // - we want to keep information up-to-date in s_
- // - we want to save some execution time
- needs_update_ = false;
- }
-
- // FIXME : ambiguous with site_set operator <<
- // template <typename E>
- // std::ostream& operator<<(std::ostream& ostr,
- // const lazy_set_<E>& s)
- // {
- // ostr << '[';
- // const unsigned n = s.nelements();
- // for (unsigned i = 0; i < n; ++i)
- // ostr << s.element(i)
- // << (i == s.nelements() - 1 ? ']' : ',');
- // return ostr;
- // }
+ frozen_ = false;
+ }
+
+ template <typename T>
+ std::ostream& operator<<(std::ostream& ostr,
+ const mln::util::set<T>& s)
+ {
+ ostr << '[';
+ const unsigned n = s.nelements();
+ for (unsigned i = 0; i < n; ++i)
+ ostr << s[i]
+ << (i == n - 1 ? ']' : ',');
+ return ostr;
+ }
# endif // ! MLN_INCLUDE_ONLY
@@ -377,4 +327,4 @@
} // end of namespace mln
-#endif // ! MLN_UTIL_LAZY_SET_HH
+#endif // ! MLN_UTIL_SET_HH
1
0
https://svn.lrde.epita.fr/svn/oln/branches/cleanup-2008/milena
Index: ChangeLog
from Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
Get rid of owns_.
* tests/border/resize_sub_image.cc,
* tests/border/get.cc,
* tests/border/resize_image_if.cc,
* tests/fun/x2x/rotation.cc,
* mln/core/translate_image.hh,
* mln/core/internal/image_if_base.hh,
* mln/core/internal/image_identity.hh,
* mln/core/internal/image_value_morpher.hh,
* mln/core/internal/check/image_fastest.hh,
* mln/core/interpolated.hh,
* mln/core/cast_image.hh,
* mln/core/pixel.hh,
* mln/core/t_image.hh,
* mln/core/image1d.hh,
* mln/core/fi_adaptor.hh,
* mln/core/image3d.hh,
* mln/core/hexa.hh,
* mln/core/tr_image.hh,
* mln/core/safe.hh,
* mln/core/concept/doc/image.hh,
* mln/level/memset_.hh,
* mln/value/stack.hh,
* mln/pw/image.hh,
* mln/pw/value.hh,
* sandbox/duhamel/translate_image.hh,
* sandbox/nivault/rotation.cc,
* sandbox/nivault/plugin-gimp/src/gimp-image.hh,
* sandbox/jardonnet/subsampling/sub_sampled_image.hh,
* sandbox/geraud/cs2d/cs2d_morpho.hh,
* sandbox/garrigues/level_set.hh,
* sandbox/garrigues/fllt/compute_level_set_fast2.hh,
* sandbox/garrigues/fllt/compute_level_set_fast.hh,
* sandbox/garrigues/fllt/compute_level_set.hh,
* sandbox/garrigues/tiled_image2d/tiled_image2d.hh,
* sandbox/garrigues/image_identity/image_value_morpher.hh,
* sandbox/garrigues/image_identity/interpolated.hh,
* sandbox/ballas/refactorization/p_run.hh,
* sandbox/ballas/refactorization/rle_image.hh,
* sandbox/ballas/refactorization/image2d.hh,
* sandbox/ballas/refactorization/concept.hh,
* sandbox/ballas/refactorization/rle_pset.hh,
* sandbox/ballas/refactorization/internal/pset_base.hh,
* sandbox/ballas/refactorization/internal/image_base.hh,
* sandbox/ballas/refactorization/box2d.hh (owns_): Rename as...
(has): ...this.
* mln/trait/image/status.txt (image2d): Set OK.
mln/core/cast_image.hh | 2 +-
mln/core/concept/doc/image.hh | 4 ++--
mln/core/fi_adaptor.hh | 8 ++++----
mln/core/hexa.hh | 4 ++--
mln/core/image1d.hh | 12 ++++++------
mln/core/image3d.hh | 12 ++++++------
mln/core/internal/check/image_fastest.hh | 2 +-
mln/core/internal/image_identity.hh | 6 +++---
mln/core/internal/image_if_base.hh | 6 +++---
mln/core/internal/image_value_morpher.hh | 6 +++---
mln/core/interpolated.hh | 10 +++++-----
mln/core/pixel.hh | 6 +++---
mln/core/safe.hh | 4 ++--
mln/core/t_image.hh | 10 +++++-----
mln/core/tr_image.hh | 10 +++++-----
mln/core/translate_image.hh | 10 +++++-----
mln/level/memset_.hh | 2 +-
mln/pw/image.hh | 4 ++--
mln/pw/value.hh | 2 +-
mln/trait/image/status.txt | 2 +-
mln/value/stack.hh | 4 ++--
sandbox/ballas/refactorization/box2d.hh | 4 ++--
sandbox/ballas/refactorization/concept.hh | 2 +-
sandbox/ballas/refactorization/image2d.hh | 2 +-
sandbox/ballas/refactorization/internal/image_base.hh | 2 +-
sandbox/ballas/refactorization/internal/pset_base.hh | 2 +-
sandbox/ballas/refactorization/p_run.hh | 4 ++--
sandbox/ballas/refactorization/rle_image.hh | 8 ++++----
sandbox/ballas/refactorization/rle_pset.hh | 4 ++--
sandbox/duhamel/translate_image.hh | 10 +++++-----
sandbox/garrigues/fllt/compute_level_set.hh | 2 +-
sandbox/garrigues/fllt/compute_level_set_fast.hh | 2 +-
sandbox/garrigues/fllt/compute_level_set_fast2.hh | 2 +-
sandbox/garrigues/image_identity/image_value_morpher.hh | 6 +++---
sandbox/garrigues/image_identity/interpolated.hh | 10 +++++-----
sandbox/garrigues/level_set.hh | 2 +-
sandbox/garrigues/tiled_image2d/tiled_image2d.hh | 8 ++++----
sandbox/geraud/cs2d/cs2d_morpho.hh | 2 +-
sandbox/jardonnet/subsampling/sub_sampled_image.hh | 10 +++++-----
sandbox/nivault/plugin-gimp/src/gimp-image.hh | 12 ++++++------
sandbox/nivault/rotation.cc | 2 +-
tests/border/get.cc | 4 ++--
tests/border/resize_image_if.cc | 2 +-
tests/border/resize_sub_image.cc | 2 +-
tests/fun/x2x/rotation.cc | 2 +-
45 files changed, 116 insertions(+), 116 deletions(-)
Index: tests/border/resize_sub_image.cc
--- tests/border/resize_sub_image.cc (revision 2011)
+++ tests/border/resize_sub_image.cc (working copy)
@@ -68,7 +68,7 @@
mln_assertion(border::get(ima) == border);
sub_image<I, box2d> sub(ima, b);
mln_assertion( sub.has (point2d(2,2)) == false &&
- sub.owns_(point2d(2,2)) == false );
+ sub.has(point2d(2,2)) == false );
// A subimage has no border so it cannot be resized => we get a compilation error as expected.
// border::resize(sub, new_border);
Index: tests/border/get.cc
--- tests/border/get.cc (revision 2011)
+++ tests/border/get.cc (working copy)
@@ -70,12 +70,12 @@
sub_image<I, box2d> sub(ima, b);
mln_assertion( sub.has (point2d(2,2)) == false &&
- sub.owns_(point2d(2,2)) == false );
+ sub.has(point2d(2,2)) == false );
mln_assertion(border::get(sub) == 0);
image_if<I, f_box2d_t> imaif(ima, f_b);
mln_assertion( imaif.has (point2d(2,2)) == false &&
- imaif.owns_(point2d(2,2)) == true );
+ imaif.has(point2d(2,2)) == true );
mln_assertion(border::get(imaif) == 51);
mln_assertion(border::get( (ima | b) | f_b ) == 0);
Index: tests/border/resize_image_if.cc
--- tests/border/resize_image_if.cc (revision 2011)
+++ tests/border/resize_image_if.cc (working copy)
@@ -71,7 +71,7 @@
my_box2d f_b(b);
image_if<I, my_box2d> imaif(ima, f_b);
mln_assertion( imaif.has (point2d(2,2)) == false &&
- imaif.owns_(point2d(2,2)) == true );
+ imaif.has(point2d(2,2)) == true );
mln_assertion(border::get(imaif) == border);
Index: tests/fun/x2x/rotation.cc
--- tests/fun/x2x/rotation.cc (revision 2011)
+++ tests/fun/x2x/rotation.cc (working copy)
@@ -60,7 +60,7 @@
for_all(p)
{
algebra::vec<2,float> v = rot1.inv()((point2d::vec_t)(point2d)p);
- if (inter.owns_(v))
+ if (inter.has(v))
out(p) = inter(v);
else
out(p) = 255;
Index: mln/trait/image/status.txt
--- mln/trait/image/status.txt (revision 2011)
+++ mln/trait/image/status.txt (working copy)
@@ -5,7 +5,7 @@
KO graph_image
KO hexa
KO image1d
-KO image2d
+ok image2d
KO image3d
KO image_if
KO image_if_interval
Index: mln/core/translate_image.hh
--- mln/core/translate_image.hh (revision 2011)
+++ mln/core/translate_image.hh (working copy)
@@ -121,7 +121,7 @@
const box2d& domain() const;
/// Test if a pixel value is accessible at \p p.
- bool owns_(const mln_psite(I)& ) const;
+ bool has(const mln_psite(I)& ) const;
/// Read-only access of pixel value at point site \p p.
mln_rvalue(I) operator()(const mln_psite(I)& p) const;
@@ -173,10 +173,10 @@
template <typename I>
inline
- bool translate_image<I>::owns_(const mln_psite(I)& p) const
+ bool translate_image<I>::has(const mln_psite(I)& p) const
{
mln_point(I) np = p - this->data_->dp_;
- return this->data_->ima_.owns_(np);
+ return this->data_->ima_.has(np);
}
template <typename I>
@@ -184,7 +184,7 @@
mln_rvalue(I)
translate_image<I>::operator()(const mln_psite(I)& p) const
{
- mln_assertion(this->owns_(p));
+ mln_assertion(this->has(p));
mln_point(I) np = p - this->data_->dp_;
return this->data_->ima_(np);
}
@@ -195,7 +195,7 @@
typename translate_image<I>::lvalue
translate_image<I>::operator()(const mln_psite(I)& p)
{
- mln_assertion(this->owns_(p));
+ mln_assertion(this->has(p));
mln_point(I) np = p - this->data_->dp_;
return this->data_->ima_(np);
}
Index: mln/core/internal/image_if_base.hh
--- mln/core/internal/image_if_base.hh (revision 2011)
+++ mln/core/internal/image_if_base.hh (working copy)
@@ -109,7 +109,7 @@
/// Test if the image owns the point site \p p.
/// The result is the same than over the underlying image.
- bool owns_(const mln_psite(I)& p) const; // Overload the def "owns_ -> has".
+ bool has(const mln_psite(I)& p) const;
protected:
@@ -169,10 +169,10 @@
template <typename I, typename F, typename E>
inline
bool
- image_if_base_<I,F,E>::owns_(const mln_psite(I)& p) const
+ image_if_base_<I,F,E>::has(const mln_psite(I)& p) const
{
mln_precondition(this->has_data());
- return this->data_->ima_.owns_(p);
+ return this->data_->ima_.has(p);
}
template <typename I, typename F, typename E>
Index: mln/core/internal/image_identity.hh
--- mln/core/internal/image_identity.hh (revision 2011)
+++ mln/core/internal/image_identity.hh (working copy)
@@ -76,7 +76,7 @@
// FIXME Matthieu: Doc! Cf. core/concept/doc/image
const mln_pset(I)& domain() const;
- bool owns_(const mln_psite(I)& p) const;
+ bool has(const mln_psite(I)& p) const;
protected:
@@ -132,10 +132,10 @@
template <typename I, typename S, typename E>
inline
bool
- image_identity_<I,S,E>::owns_(const mln_psite(I)& p) const
+ image_identity_<I,S,E>::has(const mln_psite(I)& p) const
{
mln_precondition(this->delegatee_() != 0);
- return this->delegatee_()->owns_(p);
+ return this->delegatee_()->has(p);
}
# endif // ! MLN_INCLUDE_ONLY
Index: mln/core/internal/image_value_morpher.hh
--- mln/core/internal/image_value_morpher.hh (revision 2011)
+++ mln/core/internal/image_value_morpher.hh (working copy)
@@ -56,7 +56,7 @@
public:
const mln_pset(I)& domain() const;
- bool owns_(const mln_psite(I)& p) const;
+ bool has(const mln_psite(I)& p) const;
protected:
image_value_morpher_();
@@ -83,10 +83,10 @@
template <typename I, typename E>
inline
bool
- image_value_morpher_<I,E>::owns_(const mln_psite(I)& p) const
+ image_value_morpher_<I,E>::has(const mln_psite(I)& p) const
{
mln_precondition(this->delegatee_() != 0);
- return this->delegatee_()->owns_(p);
+ return this->delegatee_()->has(p);
}
# endif // ! MLN_INCLUDE_ONLY
Index: mln/core/internal/check/image_fastest.hh
--- mln/core/internal/check/image_fastest.hh (revision 2011)
+++ mln/core/internal/check/image_fastest.hh (working copy)
@@ -128,7 +128,7 @@
{
const E* this_ = & internal::force_exact<E>(*this);
mln_precondition(this_->has_data());
- mln_precondition(this_->owns_(p));
+ mln_precondition(this_->has(p));
unsigned o = & this_->operator()(p) - this_->buffer();
mln_postcondition(p == this_->point_at_offset(o));
Index: mln/core/interpolated.hh
--- mln/core/interpolated.hh (revision 2011)
+++ mln/core/interpolated.hh (working copy)
@@ -98,10 +98,10 @@
bool has_data() const;
/// Test if a pixel value is accessible at \p p.
- using super_::owns_;
+ using super_::has;
/// Test if a pixel value is accessible at \p v.
- bool owns_(const mln::algebra::vec<I::point::dim, float>& v) const;
+ bool has(const mln::algebra::vec<I::point::dim, float>& v) const;
/// Read-only access of pixel value at point site \p p.
/// Mutable access is only OK for reading (not writing).
@@ -156,12 +156,12 @@
template <typename I>
inline
- bool interpolated<I>::owns_(const mln::algebra::vec<I::point::dim, float>& v) const
+ bool interpolated<I>::has(const mln::algebra::vec<I::point::dim, float>& v) const
{
mln_point(I) p;
for (unsigned i = 0; i < I::point::dim; ++i)
p[i] = static_cast<int>(round(v[i]));
- return this->data_->ima_.owns_(p);
+ return this->data_->ima_.has(p);
}
template <typename I>
@@ -172,7 +172,7 @@
mln_point(I) p;
for (unsigned i = 0; i < I::point::dim; ++i)
p[i] = static_cast<int>(round(v[i]));
- mln_assertion(this->data_->ima_.owns_(p));
+ mln_assertion(this->data_->ima_.has(p));
return this->data_->ima_(p);
}
Index: mln/core/cast_image.hh
--- mln/core/cast_image.hh (revision 2011)
+++ mln/core/cast_image.hh (working copy)
@@ -159,7 +159,7 @@
T
cast_image_<T,I>::operator()(const mln_psite(I)& p) const
{
- mln_precondition(this->data_->ima_.owns_(p));
+ mln_precondition(this->data_->ima_.has(p));
return mln::value::cast<T>( this->data_->ima_(p) );
}
Index: mln/core/pixel.hh
--- mln/core/pixel.hh (revision 2011)
+++ mln/core/pixel.hh (working copy)
@@ -81,7 +81,7 @@
pixel<I>::pixel(I& image, const mln_point(I)& p)
: super(image)
{
- mln_precondition(this->image_.owns_(p));
+ mln_precondition(this->image_.has(p));
change_to(p);
}
@@ -90,7 +90,7 @@
void
pixel<I>::change_to(const mln_point(I)& p)
{
- mln_precondition(this->image_.owns_(p));
+ mln_precondition(this->image_.has(p));
this->value_ptr_ = & this->image_(p);
}
@@ -103,7 +103,7 @@
return false;
int o = this->value_ptr_ - this->image_.buffer();
mln_point(I) p = this->image_.point_at_offset(o);
- return this->image_.owns_(p);
+ return this->image_.has(p);
}
# endif // ! MLN_INCLUDE_ONLY
Index: mln/core/t_image.hh
--- mln/core/t_image.hh (revision 2011)
+++ mln/core/t_image.hh (working copy)
@@ -127,7 +127,7 @@
bool has_data() const;
/// Test if a pixel value is accessible at \p p.
- bool owns_(const mln_point(I)& p) const;
+ bool has(const mln_point(I)& p) const;
/// Give the definition domain.
const box_<mln_point(I)>& domain() const;
@@ -210,10 +210,10 @@
template <typename I>
inline
bool
- t_image<I>::owns_(const mln_point(I)& p) const
+ t_image<I>::has(const mln_point(I)& p) const
{
mln_precondition(this->has_data());
- return this->delegatee_()->owns_(transpose_(p));
+ return this->delegatee_()->has(transpose_(p));
}
template <typename I>
@@ -251,7 +251,7 @@
mln_rvalue(I)
t_image<I>::operator()(const mln_point(I)& p) const
{
- mln_precondition(this->owns_(p));
+ mln_precondition(this->has(p));
return (*this->delegatee_())(transpose_(p));
}
@@ -260,7 +260,7 @@
typename internal::morpher_lvalue_<I>::ret
t_image<I>::operator()(const mln_point(I)& p)
{
- mln_precondition(this->owns_(p));
+ mln_precondition(this->has(p));
return (*this->delegatee_())(transpose_(p));
}
Index: mln/core/image1d.hh
--- mln/core/image1d.hh (revision 2011)
+++ mln/core/image1d.hh (working copy)
@@ -159,7 +159,7 @@
/// Test if \p p is valid.
- bool owns_(const point1d& p) const;
+ bool has(const point1d& p) const;
/// Give the set of values of the image.
const vset& values() const;
@@ -389,7 +389,7 @@
template <typename T>
inline
bool
- image1d<T>::owns_(const point1d& p) const
+ image1d<T>::has(const point1d& p) const
{
mln_precondition(this->has_data());
return this->data_->vb_.has(p);
@@ -400,7 +400,7 @@
const T&
image1d<T>::operator()(const point1d& p) const
{
- mln_precondition(this->owns_(p));
+ mln_precondition(this->has(p));
return this->data_->array_[p.ind()];
}
@@ -409,7 +409,7 @@
T&
image1d<T>::operator()(const point1d& p)
{
- mln_precondition(this->owns_(p));
+ mln_precondition(this->has(p));
return this->data_->array_[p.ind()];
}
@@ -436,7 +436,7 @@
const T&
image1d<T>::at(int ind) const
{
- mln_precondition(this->owns_(make::point1d(ind)));
+ mln_precondition(this->has(make::point1d(ind)));
return this->data_->array_[ind];
}
@@ -445,7 +445,7 @@
T&
image1d<T>::at(int ind)
{
- mln_precondition(this->owns_(make::point1d(ind)));
+ mln_precondition(this->has(make::point1d(ind)));
return this->data_->array_[ind];
}
Index: mln/core/fi_adaptor.hh
--- mln/core/fi_adaptor.hh (revision 2011)
+++ mln/core/fi_adaptor.hh (working copy)
@@ -326,7 +326,7 @@
const mln_value(I)&
fi_adaptor<I>::operator()(const point2d& p) const
{
- mln_precondition(this->owns_(p));
+ mln_precondition(this->has(p));
// Because Freeimage stores lena upside down.
return this->data_->array_[this->domain().len(0) - 1 - p.row()][p.col()];
@@ -336,7 +336,7 @@
mln_value(I)&
fi_adaptor<I>::operator()(const point2d& p)
{
- mln_precondition(this->owns_(p));
+ mln_precondition(this->has(p));
// Because Freeimage stores lena upside down.
return this->data_->array_[this->domain().len(0) - 1 - p.row()][p.col()];
@@ -362,7 +362,7 @@
const mln_value(I)&
fi_adaptor<I>::at(int row, int col) const
{
- mln_precondition(this->owns_(make::point2d(row, col)));
+ mln_precondition(this->has(make::point2d(row, col)));
// Because Freeimage stores lena upside down.
return this->data_->array_[this->domain().len(0) - 1 - row][col];
@@ -372,7 +372,7 @@
mln_value(I)&
fi_adaptor<I>::at(int row, int col)
{
- mln_precondition(this->owns_(make::point2d(row, col)));
+ mln_precondition(this->has(make::point2d(row, col)));
// Because Freeimage stores lena upside down.
return this->data_->array_[this->domain().len(0) - 1 - row][col];
Index: mln/core/image3d.hh
--- mln/core/image3d.hh (revision 2011)
+++ mln/core/image3d.hh (working copy)
@@ -164,7 +164,7 @@
/// Test if \p p is valid.
- bool owns_(const point3d& p) const;
+ bool has(const point3d& p) const;
/// Give the set of values of the image.
const vset& values() const;
@@ -427,7 +427,7 @@
template <typename T>
inline
bool
- image3d<T>::owns_(const point3d& p) const
+ image3d<T>::has(const point3d& p) const
{
mln_precondition(this->has_data());
return data_->vb_.has(p);
@@ -438,7 +438,7 @@
const T&
image3d<T>::operator()(const point3d& p) const
{
- mln_precondition(this->owns_(p));
+ mln_precondition(this->has(p));
return data_->array_[p.sli()][p.row()][p.col()];
}
@@ -447,7 +447,7 @@
T&
image3d<T>::operator()(const point3d& p)
{
- mln_precondition(this->owns_(p));
+ mln_precondition(this->has(p));
return data_->array_[p.sli()][p.row()][p.col()];
}
@@ -474,7 +474,7 @@
const T&
image3d<T>::at(int sli, int row, int col) const
{
- mln_precondition(this->owns_(make::point3d(sli, row, col)));
+ mln_precondition(this->has(make::point3d(sli, row, col)));
return data_->array_[sli][row][col];
}
@@ -483,7 +483,7 @@
T&
image3d<T>::at(int sli, int row, int col)
{
- mln_precondition(this->owns_(make::point3d(sli, row, col)));
+ mln_precondition(this->has(make::point3d(sli, row, col)));
return data_->array_[sli][row][col];
}
Index: mln/core/hexa.hh
--- mln/core/hexa.hh (revision 2011)
+++ mln/core/hexa.hh (working copy)
@@ -156,7 +156,7 @@
/// Test if \p p belongs to the image domain.
bool has(const psite& p) const;
- bool owns_(const psite& p) const;
+ bool has(const psite& p) const;
/// Read-only access of pixel value at hexa point site \p p.
rvalue operator()(const point2d_h& p) const;
@@ -269,7 +269,7 @@
template <typename I>
inline
bool
- hexa<I>::owns_(const psite& p) const
+ hexa<I>::has(const psite& p) const
{
return this->has(p);
}
Index: mln/core/tr_image.hh
--- mln/core/tr_image.hh (revision 2011)
+++ mln/core/tr_image.hh (working copy)
@@ -111,10 +111,10 @@
bool has_data() const;
/// Test if a pixel value is accessible at \p p.
- using super_::owns_;
+ using super_::has;
/// Test if a pixel value is accessible at \p v.
- bool owns_(const mln::algebra::vec<I::point::dim, float>& v) const;
+ bool has(const mln::algebra::vec<I::point::dim, float>& v) const;
using super_::has;
@@ -173,13 +173,13 @@
template <typename T, typename I>
inline
- bool tr_image<T,I>::owns_(const algebra::vec<I::point::dim, float>& v) const
+ bool tr_image<T,I>::has(const algebra::vec<I::point::dim, float>& v) const
{
mln_point(I) p;
algebra::vec<I::point::dim, float> v2 = this->data_->tr_.inv()(v);
for (unsigned i = 0; i < I::point::dim; ++i)
p[i] = static_cast<int>(round(v2[i]));
- return this->delegatee_().owns_(p);
+ return this->delegatee_().has(p);
}
template <typename T, typename I>
@@ -202,7 +202,7 @@
algebra::vec<I::point::dim, float> v2 = this->data_->tr_.inv()(v);
for (unsigned i = 0; i < I::point::dim; ++i)
p[i] = static_cast<int>(round(v2[i]));
- mln_assertion(this->delegatee_()->owns_(p));
+ mln_assertion(this->delegatee_()->has(p));
return (*this->delegatee_())(p);
}
Index: mln/core/safe.hh
--- mln/core/safe.hh (revision 2011)
+++ mln/core/safe.hh (working copy)
@@ -135,7 +135,7 @@
mln_rvalue(I)
safe_image<I>::operator()(const mln_psite(I)& p) const
{
- if (! this->owns_(p))
+ if (! this->has(p))
return this->data_->default_value_;
return this->data_->ima_(p);
}
@@ -146,7 +146,7 @@
safe_image<I>::operator()(const mln_psite(I)& p)
{
static mln_value(I) forget_it_;
- if (! this->owns_(p))
+ if (! this->has(p))
// so data_->default_value_ is returned but cannot be modified
return forget_it_ = this->data_->default_value_;
return this->data_->ima_(p);
Index: mln/core/concept/doc/image.hh
--- mln/core/concept/doc/image.hh (revision 2011)
+++ mln/core/concept/doc/image.hh (working copy)
@@ -80,7 +80,7 @@
* \return True if accessing the image value at \p p is
* possible, that is, does not abort the execution.
*/
- bool owns_(const psite& p) const;
+ bool has(const psite& p) const;
/*! \brief Give the definition domain of the image.
*
@@ -159,7 +159,7 @@
*
* \return True if \p p belongs to the image domain.
*
- * \invariant has(p) is true => owns_(p) is also true.
+ * \invariant has(p) is true => has(p) is also true.
*/
bool has(const psite& p) const;
Index: mln/level/memset_.hh
--- mln/level/memset_.hh (revision 2011)
+++ mln/level/memset_.hh (working copy)
@@ -147,7 +147,7 @@
mlc_is(mln_trait_image_speed(I), trait::image::speed::fastest)::check();
mln_precondition(input.has_data());
- mln_precondition(input.owns_(p));
+ mln_precondition(input.has(p));
mln_precondition(input.offset_at(p) + n <= input.ncells());
pixel<I> pix(input, p);
Index: mln/value/stack.hh
--- mln/value/stack.hh (revision 2011)
+++ mln/value/stack.hh (working copy)
@@ -259,7 +259,7 @@
algebra::vec<n, mln_value(I)>
stack_image<n,I>::read_(const psite& p) const
{
- mln_precondition(this->owns_(p));
+ mln_precondition(this->has(p));
algebra::vec<n, mln_value(I)> tmp;
for (unsigned i = 0; i < n; ++i)
tmp[i] = this->data_->imas_[i].operator()(p);
@@ -279,7 +279,7 @@
void
stack_image<n,I>::write_(const psite& p, const value& v)
{
- mln_precondition(this->owns_(p));
+ mln_precondition(this->has(p));
// FIXME!!!
for (unsigned i = 0; i < n; ++i)
this->data_->imas_[i].operator()(p) = v[i];
Index: mln/pw/image.hh
--- mln/pw/image.hh (revision 2011)
+++ mln/pw/image.hh (working copy)
@@ -132,7 +132,7 @@
/// Test if a pixel value is accessible at \p p.
- bool owns_(const mln_psite(S)& p) const;
+ bool has(const mln_psite(S)& p) const;
/// Give the definition domain.
const S& domain() const;
@@ -199,7 +199,7 @@
template <typename F, typename S>
inline
- bool image<F,S>::owns_(const mln_psite(S)& p) const
+ bool image<F,S>::has(const mln_psite(S)& p) const
{
return this->data_->pset_.has(p);
}
Index: mln/pw/value.hh
--- mln/pw/value.hh (revision 2011)
+++ mln/pw/value.hh (working copy)
@@ -93,7 +93,7 @@
value_<I>::operator()(const mln_psite(I)& p) const
{
mln_precondition(ima_ != 0);
- mln_precondition(ima_->owns_(p));
+ mln_precondition(ima_->has(p));
return (*ima_)(p);
}
Index: sandbox/duhamel/translate_image.hh
--- sandbox/duhamel/translate_image.hh (revision 2011)
+++ sandbox/duhamel/translate_image.hh (working copy)
@@ -108,7 +108,7 @@
const box2d& domain() const;
/// Test if a pixel value is accessible at \p p.
- bool owns_(const mln_psite(I)& ) const;
+ bool has(const mln_psite(I)& ) const;
/// Read-only access of pixel value at point site \p p.
mln_rvalue(I) operator()(const mln_psite(I)& p) const;
@@ -156,17 +156,17 @@
}
template <typename I>
- bool translate_image<I>::owns_(const mln_psite(I)& p) const
+ bool translate_image<I>::has(const mln_psite(I)& p) const
{
mln_point(I) np = p - this->data_->dp_;
- return this->data_->ima_.owns_(np);
+ return this->data_->ima_.has(np);
}
template <typename I>
mln_rvalue(I)
translate_image<I>::operator()(const mln_psite(I)& p) const
{
- mln_assertion(this->owns_(p));
+ mln_assertion(this->has(p));
mln_point(I) np = p - this->data_->dp_;
return this->data_->ima_(np);
}
@@ -176,7 +176,7 @@
typename translate_image<I>::lvalue
translate_image<I>::operator()(const mln_psite(I)& p)
{
- mln_assertion(this->owns_(p));
+ mln_assertion(this->has(p));
mln_point(I) np = p - this->data_->dp_;
return this->data_->ima_(np);
}
Index: sandbox/nivault/rotation.cc
--- sandbox/nivault/rotation.cc (revision 2011)
+++ sandbox/nivault/rotation.cc (working copy)
@@ -60,7 +60,7 @@
{
q0 = cos10 * p[0] - sin10 * p[1];
q1 = sin10 * p[0] + cos10 * p[1];
- if (inter.owns_(make::vec(q0, q1)))
+ if (inter.has(make::vec(q0, q1)))
{
out(p) = inter(make::vec(q0, q1));
// std::cout << "GOOD" << std::endl;
Index: sandbox/nivault/plugin-gimp/src/gimp-image.hh
--- sandbox/nivault/plugin-gimp/src/gimp-image.hh (revision 2011)
+++ sandbox/nivault/plugin-gimp/src/gimp-image.hh (working copy)
@@ -182,7 +182,7 @@
void init_(box2d box);
/// Test if \p p is valid.
- bool owns_(const point2d& p) const;
+ bool has(const point2d& p) const;
/// Give the set of values of the image.
const vset& values() const;
@@ -399,7 +399,7 @@
template <GimpImageType t>
bool
- gimp_image<t>::owns_(const point2d& p) const
+ gimp_image<t>::has(const point2d& p) const
{
mln_precondition(this->has_data());
return this->data_->b_.has(p);
@@ -410,7 +410,7 @@
const mln_value(gimp_image<t>)&
gimp_image<t>::operator()(const point& p) const
{
- // mln_precondition(this->owns_(p));
+ // mln_precondition(this->has(p));
// FIXME HERE value*) this->data_->rgn->data
static mln::value::rgb8 c;
@@ -424,7 +424,7 @@
mln_value(gimp_image<t>)&
gimp_image<t>::operator()(const point& p)
{
- // mln_precondition(this->owns_(p));
+ // mln_precondition(this->has(p));
static mln::value::rgb8 c;
gimp_pixel_rgn_get_pixel(this->data_->rgn_,
(guchar *) &c,
@@ -456,7 +456,7 @@
// const mln_value(gimp_image<t>)&
// gimp_image<t>::at(int row, int col) const
// {
-// mln_precondition(this->owns_(make::point2d(row, col)));
+// mln_precondition(this->has(make::point2d(row, col)));
// return this->data_->array_[row][col];
// }
@@ -465,7 +465,7 @@
// mln_value(gimp_image<t>)&
// gimp_image<t>::at(int row, int col)
// {
-// mln_precondition(this->owns_(make::point2d(row, col)));
+// mln_precondition(this->has(make::point2d(row, col)));
// return this->data_->array_[row][col];
// }
Index: sandbox/jardonnet/subsampling/sub_sampled_image.hh
--- sandbox/jardonnet/subsampling/sub_sampled_image.hh (revision 2011)
+++ sandbox/jardonnet/subsampling/sub_sampled_image.hh (working copy)
@@ -101,7 +101,7 @@
bool has_data() const;
/// Test if a pixel value is accessible at \p p.
- bool owns_(const mln_point(I)& p) const;
+ bool has(const mln_point(I)& p) const;
/// Give the set of values of the image.
const vset& values() const;
@@ -184,10 +184,10 @@
template <typename I>
inline
bool
- sub_sampled_image<I>::owns_(const mln_point(I)& p) const
+ sub_sampled_image<I>::has(const mln_point(I)& p) const
{
mln_precondition(this->has_data());
- return this->delegatee_()->owns_(translate_coords_(p));
+ return this->delegatee_()->has(translate_coords_(p));
}
template <typename I>
@@ -195,7 +195,7 @@
mln_rvalue(I)
sub_sampled_image<I>::operator()(const mln_point(I)& p) const
{
- mln_precondition(this->owns_(p));
+ mln_precondition(this->has(p));
return (*this->delegatee_())(translate_coords_(p));
}
@@ -204,7 +204,7 @@
typename internal::morpher_lvalue_<I>::ret
sub_sampled_image<I>::operator()(const mln_point(I)& p)
{
- mln_precondition(this->owns_(p));
+ mln_precondition(this->has(p));
return (*this->delegatee_())(translate_coords_(p));
}
Index: sandbox/geraud/cs2d/cs2d_morpho.hh
--- sandbox/geraud/cs2d/cs2d_morpho.hh (revision 2011)
+++ sandbox/geraud/cs2d/cs2d_morpho.hh (working copy)
@@ -52,7 +52,7 @@
for_all(p)
{
m.init();
- for_all(n) if (input.owns_(n))
+ for_all(n) if (input.has(n))
m.take(input(n));
output(p) = m.second() - m.first();
}
Index: sandbox/garrigues/level_set.hh
--- sandbox/garrigues/level_set.hh (revision 2011)
+++ sandbox/garrigues/level_set.hh (working copy)
@@ -347,7 +347,7 @@
mln_piter(p_set<P>) z(env.N);
for_all(z)
{
- mln_assertion(border_ima.owns_(z));
+ mln_assertion(border_ima.has(z));
border_ima(z) = true;
}
unsigned n;
Index: sandbox/garrigues/fllt/compute_level_set_fast2.hh
--- sandbox/garrigues/fllt/compute_level_set_fast2.hh (revision 2011)
+++ sandbox/garrigues/fllt/compute_level_set_fast2.hh (working copy)
@@ -250,7 +250,7 @@
// mln_piter(p_image2d<P>) z(N);
// for_all(z)
// {
-// mln_assertion(border_ima.owns_(z));
+// mln_assertion(border_ima.has(z));
// border_ima(z) = true;
// }
// unsigned n;
Index: sandbox/garrigues/fllt/compute_level_set_fast.hh
--- sandbox/garrigues/fllt/compute_level_set_fast.hh (revision 2011)
+++ sandbox/garrigues/fllt/compute_level_set_fast.hh (working copy)
@@ -244,7 +244,7 @@
// mln_piter(p_image2d<P>) z(N);
// for_all(z)
// {
-// mln_assertion(border_ima.owns_(z));
+// mln_assertion(border_ima.has(z));
// border_ima(z) = true;
// }
// unsigned n;
Index: sandbox/garrigues/fllt/compute_level_set.hh
--- sandbox/garrigues/fllt/compute_level_set.hh (revision 2011)
+++ sandbox/garrigues/fllt/compute_level_set.hh (working copy)
@@ -185,7 +185,7 @@
mln_piter(p_set<P>) z(N);
for_all(z)
{
- mln_assertion(border_ima.owns_(z));
+ mln_assertion(border_ima.has(z));
border_ima(z) = true;
}
unsigned n;
Index: sandbox/garrigues/tiled_image2d/tiled_image2d.hh
--- sandbox/garrigues/tiled_image2d/tiled_image2d.hh (revision 2011)
+++ sandbox/garrigues/tiled_image2d/tiled_image2d.hh (working copy)
@@ -178,7 +178,7 @@
/// Test if \p p is valid.
- bool owns_(const point2d& p) const;
+ bool has(const point2d& p) const;
/// Give the set of values of the image.
const vset& values() const;
@@ -329,7 +329,7 @@
template <typename T>
inline
bool
- tiled_image2d<T>::owns_(const point2d& p) const
+ tiled_image2d<T>::has(const point2d& p) const
{
mln_precondition(this->has_data());
return this->data_->b_.has(p);
@@ -340,7 +340,7 @@
const T&
tiled_image2d<T>::operator()(const point2d& p) const
{
- mln_precondition(this->owns_(p));
+ mln_precondition(this->has(p));
unsigned page_n = layout::image_layout::page_at(*this, p);
// note: although the page instance goes
// out of scope, the reference stays valid
@@ -354,7 +354,7 @@
T&
tiled_image2d<T>::operator()(const point2d& p)
{
- mln_precondition(this->owns_(p));
+ mln_precondition(this->has(p));
unsigned page_n = layout::image_layout::page_at(*this, p);
// note: although the page instance goes
// out of scope, the reference stays valid
Index: sandbox/garrigues/image_identity/image_value_morpher.hh
--- sandbox/garrigues/image_identity/image_value_morpher.hh (revision 2011)
+++ sandbox/garrigues/image_identity/image_value_morpher.hh (working copy)
@@ -55,7 +55,7 @@
public:
const mln_pset(I)& domain() const;
- bool owns_(const mln_psite(I)& p) const;
+ bool has(const mln_psite(I)& p) const;
protected:
image_value_morpher_();
@@ -79,10 +79,10 @@
template <typename I, typename E>
bool
- image_value_morpher_<I,E>::owns_(const mln_psite(I)& p) const
+ image_value_morpher_<I,E>::has(const mln_psite(I)& p) const
{
mln_precondition(this->delegatee_() != 0);
- return this->delegatee_()->owns_(p);
+ return this->delegatee_()->has(p);
}
# endif // ! MLN_INCLUDE_ONLY
Index: sandbox/garrigues/image_identity/interpolated.hh
--- sandbox/garrigues/image_identity/interpolated.hh (revision 2011)
+++ sandbox/garrigues/image_identity/interpolated.hh (working copy)
@@ -96,10 +96,10 @@
bool has_data() const;
/// Test if a pixel value is accessible at \p p.
- using super_::owns_;
+ using super_::has;
/// Test if a pixel value is accessible at \p v.
- bool owns_(const mln::algebra::vec<I::point::dim, float>& v) const;
+ bool has(const mln::algebra::vec<I::point::dim, float>& v) const;
/// Read-only access of pixel value at point site \p p.
/// Mutable access is only OK for reading (not writing).
@@ -149,12 +149,12 @@
}
template <typename I>
- bool interpolated<I>::owns_(const mln::algebra::vec<I::point::dim, float>& v) const
+ bool interpolated<I>::has(const mln::algebra::vec<I::point::dim, float>& v) const
{
mln_point(I) p;
for (unsigned i = 0; i < I::point::dim; ++i)
p[i] = static_cast<int>(round(v[i]));
- return this->data_->ima_.owns_(p);
+ return this->data_->ima_.has(p);
}
template <typename I>
@@ -164,7 +164,7 @@
mln_point(I) p;
for (unsigned i = 0; i < I::point::dim; ++i)
p[i] = static_cast<int>(round(v[i]));
- mln_assertion(this->data_->ima_.owns_(p));
+ mln_assertion(this->data_->ima_.has(p));
return this->data_->ima_(p);
}
Index: sandbox/ballas/refactorization/p_run.hh
--- sandbox/ballas/refactorization/p_run.hh (revision 2011)
+++ sandbox/ballas/refactorization/p_run.hh (working copy)
@@ -27,7 +27,7 @@
p_run(const P& start, std::size_t len);
void set_run(const P& start, std::size_t len);
- bool owns_(const P& p) const;
+ bool has(const P& p) const;
std::size_t nsites() const;
std::size_t length() const;
@@ -87,7 +87,7 @@
template <typename P>
inline
bool
- p_run<P>::owns_(const P& p) const
+ p_run<P>::has(const P& p) const
{
assert(is_valid_);
bool res = true;
Index: sandbox/ballas/refactorization/rle_image.hh
--- sandbox/ballas/refactorization/rle_image.hh (revision 2011)
+++ sandbox/ballas/refactorization/rle_image.hh (working copy)
@@ -35,7 +35,7 @@
lvalue operator() (const rle_psite<P>& psite);
bool has_data() const;
- bool owns_(const rle_psite<P>& ps) const;
+ bool has(const rle_psite<P>& ps) const;
const pset& domain() const;
protected:
@@ -75,7 +75,7 @@
rle_image<P, T>::operator() (const rle_psite<P>& psite)
const
{
- assert(this->owns_(psite));
+ assert(this->has(psite));
return this->values_[psite.p_of_run()];
}
@@ -84,7 +84,7 @@
typename rle_image<P, T>::lvalue
rle_image<P, T>::operator() (const rle_psite<P>& psite)
{
- assert(this->owns_(psite));
+ assert(this->has(psite));
return this->values_[psite.p_of_run()];
}
@@ -99,7 +99,7 @@
template <typename P, typename T>
inline
bool
- rle_image<P, T>::owns_(const rle_psite<P>& ps) const
+ rle_image<P, T>::has(const rle_psite<P>& ps) const
{
if (!this->has_data())
return false;
Index: sandbox/ballas/refactorization/image2d.hh
--- sandbox/ballas/refactorization/image2d.hh (revision 2011)
+++ sandbox/ballas/refactorization/image2d.hh (working copy)
@@ -32,7 +32,7 @@
// const vset& values() const;
bool is_ready() const;
- bool owns_(const point2d<int>& p) const;
+ bool has(const point2d<int>& p) const;
const box2d<int>& domain() const;
const T& operator()(const point2d<int>& p) const;
Index: sandbox/ballas/refactorization/concept.hh
--- sandbox/ballas/refactorization/concept.hh (revision 2011)
+++ sandbox/ballas/refactorization/concept.hh (working copy)
@@ -141,7 +141,7 @@
typedef psite;
rvalue operator() (const psite&) const;
lvalue operator() (const psite);
- bool owns_(const psite&) const;
+ bool has(const psite&) const;
bool has(const psite&) const;
typedef pset;
Index: sandbox/ballas/refactorization/rle_pset.hh
--- sandbox/ballas/refactorization/rle_pset.hh (revision 2011)
+++ sandbox/ballas/refactorization/rle_pset.hh (working copy)
@@ -60,7 +60,7 @@
rle_pset();
/// Test is \p p belongs to this point set.
- bool owns_(const rle_psite<P>& ps) const;
+ bool has(const rle_psite<P>& ps) const;
typename std::size_t nsites() const;
void insert(const p_run<P>& pr);
@@ -92,7 +92,7 @@
template <typename P>
inline
bool
- rle_pset<P>::owns_(const rle_psite<P>& ps) const
+ rle_pset<P>::has(const rle_psite<P>& ps) const
{
if (ps.p_of_run() < nruns()
&& ps.p_in_run() < con_[ps.p_of_run()].length())
Index: sandbox/ballas/refactorization/internal/pset_base.hh
--- sandbox/ballas/refactorization/internal/pset_base.hh (revision 2011)
+++ sandbox/ballas/refactorization/internal/pset_base.hh (working copy)
@@ -38,7 +38,7 @@
bool
pset_base_<P, E>::has(const P& ps) const
{
- return exact(this)->owns_(ps);
+ return exact(this)->has(ps);
}
# endif // ! MLN_INCLUDE_ONLY
Index: sandbox/ballas/refactorization/internal/image_base.hh
--- sandbox/ballas/refactorization/internal/image_base.hh (revision 2011)
+++ sandbox/ballas/refactorization/internal/image_base.hh (working copy)
@@ -38,7 +38,7 @@
bool
image_base_<S, E>::has(const psite& ps) const
{
- return exact(this)->owns_(ps);
+ return exact(this)->has(ps);
}
Index: sandbox/ballas/refactorization/box2d.hh
--- sandbox/ballas/refactorization/box2d.hh (revision 2011)
+++ sandbox/ballas/refactorization/box2d.hh (working copy)
@@ -36,7 +36,7 @@
box2d();
box2d(const site& pmin, const site& pmax);
- bool owns_(const site& p) const;
+ bool has(const site& p) const;
protected:
point2d<C> pmin_, pmax_;
@@ -98,7 +98,7 @@
template <typename C>
inline
bool
- box2d<C>::owns_(const site& p) const
+ box2d<C>::has(const site& p) const
{
for (unsigned i = 0; i < C::dim; ++i)
if (p[i] < pmin_[i] || p[i] > pmax_[i])
1
0
11 Jun '08
https://svn.lrde.epita.fr/svn/oln/branches/cleanup-2008/milena
Index: ChangeLog
from Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
Update image2d with new image properties.
* doc/tutorial/examples/image2d.cc: New.
* mln/trait/image/props.hh (localization): Fix missing types.
(space_from_point): Update.
* mln/trait/image/print.hh: Fix missing brackets.
* mln/trait/images.hh: Update macros.
(mln_trait_image_io_from_): Update.
(mln_trait_image_data_from_): Remove; obsolete.
* mln/core/macros.hh (mln_dpsite, mln_dpsite_): New.
* mln/core/internal/image_base.hh
(dpoint, coord, bbox): Remove cause not general.
(owns_): Remove; it is obsolete/replaced by 'has'.
* mln/core/internal/check/image_fastest.hh
(offset_at): Return std::size_t; now accept more types for
the p argument.
(image_fastest_): Update ctor.
* mln/core/concept/image.hh: Layout doc.
(mln_point, point): Rename as...
(mln_site, site): ...these.
(coord, dpoint): Remove; obsolete.
* mln/core/image2d.hh: Likewise.
(image_): Update traits.
(owns_): Rename as...
(has): ...this.
doc/tutorial/examples/image2d.cc | 10 ++++
mln/core/concept/image.hh | 66 +++++++++++++------------------
mln/core/image2d.hh | 45 +++++++++++++--------
mln/core/internal/check/image_fastest.hh | 24 +++++------
mln/core/internal/image_base.hh | 24 -----------
mln/core/macros.hh | 6 ++
mln/trait/image/print.hh | 30 +++++++-------
mln/trait/image/props.hh | 13 ++++--
mln/trait/images.hh | 53 +++++++-----------------
9 files changed, 128 insertions(+), 143 deletions(-)
Index: doc/tutorial/examples/image2d.cc
--- doc/tutorial/examples/image2d.cc (revision 0)
+++ doc/tutorial/examples/image2d.cc (revision 0)
@@ -0,0 +1,10 @@
+# include <mln/core/image2d.hh>
+
+
+int main()
+{
+ using namespace mln;
+
+ image2d<char> ima(2, 3);
+ mln_invariant(ima.nsites() == 6);
+}
Index: mln/trait/image/props.hh
--- mln/trait/image/props.hh (revision 2010)
+++ mln/trait/image/props.hh (working copy)
@@ -379,8 +379,15 @@
struct none : any { std::string name() const { return "localization::none"; } };
struct space : any { std::string name() const { return "localization::space"; } };
struct grid : space { protected: grid() {} };
+ struct isotropic_grid
+ : grid { std::string name() const { return "localization::isotropic_grid"; } };
+ struct basic_grid
+ : isotropic_grid { std::string name() const { return "localization::basic_grid"; } };
+ struct anisotropic_grid
+ : grid { std::string name() const { return "localization::anisotropic_grid"; } };
};
+
// dimension: /any/
// |
// + -- none
@@ -566,15 +573,15 @@
template <>
struct space_from_point<point1d>
- { typedef trait::image::space::one_d ret; };
+ { typedef trait::image::dimension::one_d ret; };
template <>
struct space_from_point<point2d>
- { typedef trait::image::space::two_d ret; };
+ { typedef trait::image::dimension::two_d ret; };
template <>
struct space_from_point<point3d>
- { typedef trait::image::space::three_d ret; };
+ { typedef trait::image::dimension::three_d ret; };
/// \}
} // end of namespace mln::trait::image
Index: mln/trait/image/print.hh
--- mln/trait/image/print.hh (revision 2010)
+++ mln/trait/image/print.hh (working copy)
@@ -68,21 +68,21 @@
mlc_is_a(I, Image)::check();
typedef mln::trait::image_<I> the;
ostr << "{ "
- << typename the::category.name() << ", "
- << typename the::speed.name() << ", "
- << typename the::size.name() << ", "
- << typename the::value_access.name() << ", "
- << typename the::value_storage.name() << ", "
- << typename the::value_browsing.name() << ", "
- << typename the::value_io.name() << ", "
- << typename the::localization.name() << ", "
- << typename the::dimension.name() << ", "
- << typename the::ext_domain.name() << ", "
- << typename the::ext_value.name() << ", "
- << typename the::ext_io.name() << ", "
- << typename the::kind.name() << ", "
- << typename the::nature.name() << ", "
- << typename the::quant.name() << " }" << std::endl;
+ << typename the::category().name() << ", "
+ << typename the::speed().name() << ", "
+ << typename the::size().name() << ", "
+ << typename the::value_access().name() << ", "
+ << typename the::value_storage().name() << ", "
+ << typename the::value_browsing().name() << ", "
+ << typename the::value_io().name() << ", "
+ << typename the::localization().name() << ", "
+ << typename the::dimension().name() << ", "
+ << typename the::ext_domain().name() << ", "
+ << typename the::ext_value().name() << ", "
+ << typename the::ext_io().name() << ", "
+ << typename the::kind().name() << ", "
+ << typename the::nature().name() << ", "
+ << typename the::quant().name() << " }" << std::endl;
}
template <typename I>
Index: mln/trait/images.hh
--- mln/trait/images.hh (revision 2010)
+++ mln/trait/images.hh (working copy)
@@ -47,52 +47,33 @@
# include <mln/metal/if.hh>
# include <mln/metal/is_const.hh>
-// category
-// speed
-// size
-// value_access
-// value_storage
-// value_browsing
-// value_io
-// localization
-// dimension
-// ext_domain
-// ext_value
-// ext_io
-// kind
-// nature
-// quant
+
# define mln_trait_image_category(I) typename mln::trait::image_< I >::category
+# define mln_trait_image_speed(I) typename mln::trait::image_< I >::speed
+# define mln_trait_image_size(I) typename mln::trait::image_< I >::size
+
+# define mln_trait_image_value_access(I) typename mln::trait::image_< I >::value_access
+# define mln_trait_image_value_storage(I) typename mln::trait::image_< I >::value_storage
+# define mln_trait_image_value_browsing(I) typename mln::trait::image_< I >::value_browsing
+# define mln_trait_image_value_io(I) typename mln::trait::image_< I >::value_io
+
+# define mln_trait_image_localization(I) typename mln::trait::image_< I >::localization
+# define mln_trait_image_dimension(I) typename mln::trait::image_< I >::dimension
+
+# define mln_trait_image_ext_domain(I) typename mln::trait::image_< I >::ext_domain
+# define mln_trait_image_ext_value(I) typename mln::trait::image_< I >::ext_value
+# define mln_trait_image_ext_io(I) typename mln::trait::image_< I >::ext_io
# define mln_trait_image_kind(I) typename mln::trait::image_< I >::kind
+# define mln_trait_image_nature(I) typename mln::trait::image_< I >::nature
# define mln_trait_image_quant(I) typename mln::trait::image_< I >::quant
-# define mln_trait_image_value(I) typename mln::trait::image_< I >::value
-
-# define mln_trait_image_access(I) typename mln::trait::image_< I >::access
-# define mln_trait_image_space(I) typename mln::trait::image_< I >::space
-# define mln_trait_image_size(I) typename mln::trait::image_< I >::size
-# define mln_trait_image_support(I) typename mln::trait::image_< I >::support
-
-# define mln_trait_image_border(I) typename mln::trait::image_< I >::border
-# define mln_trait_image_neighb(I) typename mln::trait::image_< I >::neighb
-# define mln_trait_image_data(I) typename mln::trait::image_< I >::data
-# define mln_trait_image_io(I) typename mln::trait::image_< I >::io
-# define mln_trait_image_speed(I) typename mln::trait::image_< I >::speed
// for io: I const => read_only, otherwise like I
# define mln_trait_image_io_from_(I) \
-mlc_if( mlc_is_const(I), mln::trait::image::io::read_only, mln_trait_image_io(I) )
+mlc_if( mlc_is_const(I), mln::trait::image::value_io::read_only, mln_trait_image_value_io(I) )
-// for data: if raw or linear => stored, otherwise like I (i.e., either stored or computed)
-#define mln_trait_image_data_from_(I) typename \
-mln::metal::if_< mln::metal::or_< mlc_equal( mln_trait_image_data(I), \
- mln::trait::image::data::raw), \
- mlc_equal( mln_trait_image_data(I), \
- mln::trait::image::data::linear) >, \
- mln::trait::image::data::stored, \
- mln_trait_image_data(I) >::ret
namespace mln
Index: mln/core/macros.hh
--- mln/core/macros.hh (revision 2010)
+++ mln/core/macros.hh (working copy)
@@ -94,6 +94,12 @@
# define mln_dpoint_(T) T::dpoint
/// \}
+/// Shortcuts to access the dpsite type associated to T.
+/// \{
+# define mln_dpsite(T) typename T::dpsite
+# define mln_dpsite_(T) T::dpsite
+/// \}
+
// e
Index: mln/core/internal/image_base.hh
--- mln/core/internal/image_base.hh (revision 2010)
+++ mln/core/internal/image_base.hh (working copy)
@@ -106,13 +106,6 @@
/// Point associated type.
typedef mln_site(S) site;
- /// Dpoint associated type.
- typedef mln_dpoint(site) dpoint;
-
- /// Coordinate associated type.
- typedef mln_coord(site) coord;
-
-
/// Forward Site_Iterator associated type.
typedef mln_fwd_piter(S) fwd_piter;
@@ -123,12 +116,6 @@
/// Test if \p p belongs to the image domain.
bool has(const psite& p) const;
- // FIXME: Keep this default (owns_ is based on has)?
- bool owns_(const psite& p) const;
-
- /// Give a bounding box of the image domain.
- const box_<site>& bbox() const;
-
/// Give the number of sites of the image domain.
std::size_t nsites() const;
@@ -208,18 +195,11 @@
template <typename S, typename E>
inline
- bool
- image_base_<S,E>::owns_(const psite& p) const
- {
- mln_precondition(exact(this)->has_data());
- return exact(this)->has(p);
- }
-
- template <typename S, typename E>
- inline
std::size_t
image_base_<S,E>::nsites() const
{
+ mlc_equal(mln_trait_site_set_nsites(S),
+ mln::trait::site_set::nsites::known)::check();
mln_precondition(exact(this)->has_data());
return exact(this)->domain().nsites();
}
Index: mln/core/internal/check/image_fastest.hh
--- mln/core/internal/check/image_fastest.hh (revision 2010)
+++ mln/core/internal/check/image_fastest.hh (working copy)
@@ -32,6 +32,8 @@
*
* \brief Class that statically checks the interface of fastest
* images.
+ *
+ * \todo Check and convert p in offset_at towards E::psite.
*/
# include <mln/core/internal/force_exact.hh>
@@ -52,9 +54,9 @@
struct image_fastest_
{
- /*! \brief Give the offset of the point \p p.
+ /*! \brief Give the offset of the site \p p.
*
- * \param[in] p A generalized point.
+ * \param[in] p A site.
*
* \warning This method is final.
*
@@ -62,8 +64,8 @@
* \post p == point_at_offset(result)
*/
template <typename P>
- unsigned
- offset_at(const Point_Site<P>& p) const;
+ std::size_t
+ offset_at(const P& p) const;
protected:
image_fastest_();
@@ -84,15 +86,15 @@
inline
image_fastest_<E,B>::image_fastest_()
{
- typedef mln_point(E) point;
- typedef mln_dpoint(E) dpoint;
+ typedef mln_site(E) site;
+ typedef mln_dpsite(E) dpsite;
typedef mln_fwd_pixter(E) fwd_pixter;
typedef mln_bkd_pixter(E) bkd_pixter;
- int (E::*m1)(const dpoint&) const = & E::offset;
+ int (E::*m1)(const dpsite&) const = & E::offset;
m1 = 0;
- point (E::*m2)(unsigned) const = & E::point_at_offset;
+ site (E::*m2)(unsigned) const = & E::point_at_offset;
m2 = 0;
unsigned (E::*m3)() const = & E::border;
m3 = 0;
@@ -121,12 +123,10 @@
template <typename E, typename B>
template <typename P>
inline
- unsigned // FIXME: std::size_t?
- image_fastest_<E,B>::offset_at(const Point_Site<P>& p_) const
+ std::size_t
+ image_fastest_<E,B>::offset_at(const P& p) const
{
- // FIXME: check that P is mln_point(E)
const E* this_ = & internal::force_exact<E>(*this);
- const P& p = exact(p_);
mln_precondition(this_->has_data());
mln_precondition(this_->owns_(p));
Index: mln/core/concept/image.hh
--- mln/core/concept/image.hh (revision 2010)
+++ mln/core/concept/image.hh (working copy)
@@ -73,42 +73,35 @@
typedef Image<void> category;
/*
- // to be provided in concrete image classes:
-
- typedef mesh;
-
- typedef value;
- typedef rvalue;
- typedef lvalue;
- typedef vset;
-
- const vset& values() const;
-
- bool owns_(const psite& p) const;
- const pset& domain() const;
-
- rvalue operator()(const psite& p) const;
- lvalue operator()(const psite& p);
-
- typedef skeleton;
-
-
// provided by internal::image_base_:
typedef pset;
- typedef point;
+ typedef site;
typedef psite;
- typedef coord;
- typedef dpoint;
-
typedef fwd_piter;
typedef bkd_piter;
bool has(const psite& p) const;
- std::size_t nsites() const;
+ std::size_t nsites() const; // If relevant.
bool has_data() const;
+
+ // to be provided in concrete image classes:
+
+ typedef value;
+
+ typedef vset;
+ const vset& values() const;
+
+ typedef rvalue;
+ typedef lvalue;
+ rvalue operator()(const psite& p) const;
+ lvalue operator()(const psite& p);
+
+ const pset& domain() const;
+
+ typedef skeleton;
*/
protected:
@@ -125,17 +118,18 @@
// provided by internal::image_base_:
typedef mln_pset(E) pset;
- typedef mln_point(E) point;
+ typedef mln_site(E) site;
typedef mln_psite(E) psite;
- typedef mln_coord(E) coord;
- typedef mln_dpoint(E) dpoint;
-
typedef mln_fwd_piter(E) fwd_piter;
typedef mln_bkd_piter(E) bkd_piter;
bool (E::*m1)(const psite& p) const = & E::has;
m1 = 0;
+ std::size_t (E::*m2)() const = & E::nsites;
+ m2 = 0;
+ bool (E::*m3)() const = & E::has_data;
+ m3 = 0;
// to be provided in concrete image classes:
@@ -143,13 +137,8 @@
typedef mln_rvalue(E) rvalue;
typedef mln_lvalue(E) lvalue;
- typedef typename E::skeleton skeleton;
-
- bool (E::*m3)() const = & E::has_data;
- m3 = 0;
- bool (E::*m4)(const psite& p) const = & E::owns_;
- m4 = 0;
- const pset& (E::*m5)() const = & E::domain;
+ typedef mln_vset(E) vset;
+ const vset& (E::*m5)() const = & E::values;
m5 = 0;
rvalue (E::*m6)(const psite& p) const = & E::operator();
@@ -157,9 +146,10 @@
lvalue (E::*m7)(const psite& p) = & E::operator();
m7 = 0;
- typedef mln_vset(E) vset;
- const vset& (E::*m8)() const = & E::values;
+ const pset& (E::*m8)() const = & E::domain;
m8 = 0;
+
+ typedef typename E::skeleton skeleton;
}
# endif // ! MLN_INCLUDE_ONLY
Index: mln/core/image2d.hh
--- mln/core/image2d.hh (revision 2010)
+++ mln/core/image2d.hh (working copy)
@@ -88,17 +88,25 @@
template <typename T>
struct image_< image2d<T> > : default_image_< T, image2d<T> >
{
+ // misc
typedef trait::image::category::primary category;
-
- typedef trait::image::access::random access;
- typedef trait::image::space::two_d space;
+ typedef trait::image::speed::fastest speed;
typedef trait::image::size::regular size;
- typedef trait::image::support::aligned support;
- typedef trait::image::border::stored border;
- typedef trait::image::data::raw data;
- typedef trait::image::io::read_write io;
- typedef trait::image::speed::fastest speed;
+ // value
+ typedef trait::image::value_access::direct value_access;
+ typedef trait::image::value_storage::one_block value_storage;
+ typedef trait::image::value_browsing::site_wise_only value_browsing;
+ typedef trait::image::value_io::read_write value_io;
+
+ // site / domain
+ typedef trait::image::localization::basic_grid localization;
+ typedef trait::image::dimension::two_d dimension;
+
+ // extended domain
+ typedef trait::image::ext_domain::extendable ext_domain;
+ typedef trait::image::ext_value::multiple ext_value;
+ typedef trait::image::ext_io::read_write ext_io;
};
} // end of namespace mln::trait
@@ -116,12 +124,15 @@
{
// Warning: just to make effective types appear in Doxygen:
typedef box2d pset;
+
typedef point2d psite;
- typedef point2d point;
- typedef dpoint2d dpoint;
+ typedef point2d site;
+ typedef dpoint2d dpsite;
+
typedef mln_fwd_piter(box2d) fwd_piter;
typedef mln_bkd_piter(box2d) bkd_piter;
- typedef line_piter_<point> line_piter;
+
+ typedef line_piter_<point2d> line_piter;
// End of warning.
@@ -160,7 +171,7 @@
/// Test if \p p is valid.
- bool owns_(const point2d& p) const;
+ bool has(const point2d& p) const;
/// Give the set of values of the image.
const vset& values() const;
@@ -422,7 +433,7 @@
template <typename T>
inline
bool
- image2d<T>::owns_(const point2d& p) const
+ image2d<T>::has(const point2d& p) const
{
mln_precondition(this->has_data());
return this->data_->vb_.has(p);
@@ -433,7 +444,7 @@
const T&
image2d<T>::operator()(const point2d& p) const
{
- mln_precondition(this->owns_(p));
+ mln_precondition(this->has(p));
return this->data_->array_[p.row()][p.col()];
}
@@ -442,7 +453,7 @@
T&
image2d<T>::operator()(const point2d& p)
{
- mln_precondition(this->owns_(p));
+ mln_precondition(this->has(p));
return this->data_->array_[p.row()][p.col()];
}
@@ -469,7 +480,7 @@
const T&
image2d<T>::at(int row, int col) const
{
- mln_precondition(this->owns_(make::point2d(row, col)));
+ mln_precondition(this->has(make::point2d(row, col)));
return this->data_->array_[row][col];
}
@@ -478,7 +489,7 @@
T&
image2d<T>::at(int row, int col)
{
- mln_precondition(this->owns_(make::point2d(row, col)));
+ mln_precondition(this->has(make::point2d(row, col)));
return this->data_->array_[row][col];
}
1
0
10 Jun '08
https://svn.lrde.epita.fr/svn/oln/branches/cleanup-2008/milena
Index: ChangeLog
from Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
Introduce the new set of image properties.
* mln/trait/image/props.hh: New set of image properties.
* mln/trait/image/print.hh: Update.
* mln/trait/images.hh: Update.
image/print.hh | 27 +-
image/props.hh | 556 +++++++++++++++++++++++++++++++++++++++++++++------------
images.hh | 98 ++++++----
3 files changed, 514 insertions(+), 167 deletions(-)
Index: mln/trait/image/props.hh
--- mln/trait/image/props.hh (revision 2009)
+++ mln/trait/image/props.hh (working copy)
@@ -38,6 +38,177 @@
# include <mln/trait/value/kind.hh>
+
+// Properties of images.
+// =====================
+
+// * misc
+
+// category: /any/
+// |
+// + -- primary
+// |
+// + -- /morpher/
+// |
+// + -- domain_morpher
+// |
+// + -- value_morpher
+// |
+// + -- identity_morpher
+
+// speed: /any/
+// |
+// + -- slow
+// |
+// + -- fast
+// |
+// + -- fastest
+
+// size: /any/
+// |
+// + -- regular
+// |
+// + -- huge
+
+// * value
+
+// value_access: /any/
+// |
+// + -- direct
+// |
+// + -- computed
+
+// value_storage:/any/
+// |
+// + -- /organized/
+// | |
+// | + -- singleton
+// | |
+// | + -- one_block
+// | |
+// | + -- piecewise
+// |
+// + -- disrupted
+
+// value_browsing:/any/
+// |
+// + -- site_wise_only
+// |
+// + ------- cell_wise
+// | \
+// + -- value_wise \
+// \ \
+// ---- + -- cell_and_value_wise
+
+// value_io: /any/
+// |
+// + -- read_only
+// |
+// + -- read_write
+
+// * site localization
+
+// localization: /any/
+// |
+// + -- none
+// |
+// + -- space
+// |
+// + -- /grid/
+// |
+// + -- isotropic_grid
+// | |
+// | + -- basic_grid
+// |
+// + -- anisotropic_grid
+
+// dimension: /any/
+// |
+// + -- none
+// |
+// + -- /some/
+// |
+// + -- one_d
+// |
+// + -- two_d
+// |
+// + -- three_d
+
+// * extended domain
+
+// ext_domain: /any/
+// |
+// + -- none
+// |
+// + -- /some/
+// |
+// + -- fixed
+// | |
+// | + -- infinite
+// |
+// + -- extendable
+
+// ext_value: /any/
+// |
+// + -- irrelevant
+// |
+// + -- single
+// |
+// + -- multiple
+
+// ext_io: /any/
+// |
+// + -- irrelevant
+// |
+// + -- read_only
+// |
+// + -- read_write
+
+// * data (related to I::value)
+
+// kind: /any/
+// |
+// + -- color
+// |
+// + -- gray
+// |
+// + ----------- label
+// | |
+// | +-- named
+// + -- /logic/ |
+// | | |
+// | + -- /mvlogic/
+// | | |
+// | | + -- binary
+// | | |
+// | | + -- ternary
+// | |
+// | + -- fuzzy
+// |
+// + -- data
+// |
+// |
+// + -- /map/
+// |
+// + -- distance
+
+// nature: /any/
+// |
+// + -- scalar
+// |
+// + -- vectorial
+// |
+// + -- structed
+// |
+// + -- pointer
+
+// quant: /any/
+// |
+// + -- low
+// |
+// + -- high
+
+
namespace mln
{
@@ -47,43 +218,23 @@
namespace image
{
- // FIXME: For the record:
-
- // template <typename I>
- // struct undefined_image_
- // {
- // typedef undef category; // primary, domain_morpher, value_morpher,
- // // or identity_morpher < morpher
-
- // // related to I::value
- // typedef undef kind; // color, gray, binary < logic < label, data
- // typedef undef quant; // low or high
- // typedef undef value; // scalar, vectorial, structed, pointer
- // // FIXME: Make the difference between homogeneous and heterogeneous vectors...
-
- // // related to I::pset
- // typedef undef access; // random, browsing
- // typedef undef space; // one_d, two_d, three_d
- // typedef undef size; // huge or regular
- // typedef undef support; // irregular, aligned < regular
-
- // // global
- // typedef undef border; // none, { stored, computed } < some
- // typedef undef neighb; // none, some
- // typedef undef data; // raw < linear < stored, computed
- // typedef undef io; // read_only < read, write_only < write, read_write < both read'n write
- // typedef undef speed; // slow, fast, or fastest
- // };
-
- // FIXME: Add nice pictures of those hierarchies.
-
-
+// category: /any/
+// |
+// + -- primary
+// |
+// + -- /morpher/
+// |
+// + -- domain_morpher
+// |
+// + -- value_morpher
+// |
+// + -- identity_morpher
struct category
{
- struct any {};
+ struct any { protected: any() {} };
struct primary : any { std::string name() const { return "category::primary"; } };
- struct morpher : any {};
+ struct morpher : any { protected: morpher() {} };
struct domain_morpher
: morpher { std::string name() const { return "category::domain_morpher"; } };
struct value_morpher
@@ -93,113 +244,286 @@
};
- typedef mln::trait::value::kind kind; // Fetch the 'kind' structure from value traits.
-
-
- struct data
- {
- struct any {};
- struct computed : any { std::string name() const { return "data::computed"; } };
- struct stored : any { std::string name() const { return "data::stored"; } };
- struct linear
- : stored { std::string name() const { return "data::linear"; } };
- struct raw
- : linear { std::string name() const { return "data::raw"; } };
- };
-
- struct quant
- {
- struct any {};
- struct low : any { std::string name() const { return "quant::low"; } };
- struct high : any { std::string name() const { return "quant::high"; } };
- };
-
- struct value
- {
- struct any {};
- struct scalar : any { std::string name() const { return "value::scalar"; } };
- struct vectorial : any { std::string name() const { return "value::vectorial"; } };
- struct structed : any { std::string name() const { return "value::structed"; } };
- struct pointer : any { std::string name() const { return "value::pointer"; } };
-
- struct fixme // So FIXME!
- : any { std::string name() const { return "space::fixme"; } };
- };
-
+// speed: /any/
+// |
+// + -- slow
+// |
+// + -- fast
+// |
+// + -- fastest
- struct access
+ struct speed
{
- struct any {};
- struct random : any { std::string name() const { return "access::random"; } };
- struct browsing : any { std::string name() const { return "access::browsing"; } };
+ struct any { protected: any() {} };
+ struct slow : any { std::string name() const { return "speed::slow"; } };
+ struct fast : any { std::string name() const { return "speed::fast"; } };
+ struct fastest
+ : fast { std::string name() const { return "speed::fastest"; } };
};
- struct space
- {
- struct any {};
- struct one_d : any { std::string name() const { return "space::one_d"; } };
- struct two_d : any { std::string name() const { return "space::two_d"; } };
- struct three_d : any { std::string name() const { return "space::three_d"; } };
- struct fixme_ // So FIXME!
- : any { std::string name() const { return "space::fixme_"; } };
- };
+// size: /any/
+// |
+// + -- regular
+// |
+// + -- huge
struct size
{
- struct any {};
+ struct any { protected: any() {} };
struct huge : any { std::string name() const { return "size::huge"; } };
struct regular : any { std::string name() const { return "size::regular"; } };
};
- struct support
- {
- struct any {};
- struct irregular : any { std::string name() const { return "support::irregular"; } };
- struct regular : any { std::string name() const { return "support::regular"; } };
- struct aligned
- : regular { std::string name() const { return "support::aligned"; } };
- struct fixme_ // So FIXME!
- : any { std::string name() const { return "support::fixme_"; } };
- };
+// value_access: /any/
+// |
+// + -- direct
+// |
+// + -- computed
+
+ struct value_access
+ {
+ struct any { protected: any() {} };
+ struct direct : any { std::string name() const { return "value_access::direct"; } };
+ struct computed : any { std::string name() const { return "value_access::computed"; } };
+ };
+
+
+// value_storage:/any/
+// |
+// + -- /organized/
+// | |
+// | + -- singleton
+// | |
+// | + -- one_block
+// | |
+// | + -- piecewise
+// |
+// + -- disrupted
+
+ struct value_storage
+ {
+ struct any { protected: any() {} };
+ struct organized
+ : any { protected: organized() {} };
+ struct singleton
+ : organized { std::string name() const { return "value_storage::singleton"; } };
+ struct one_block
+ : organized { std::string name() const { return "value_storage::one_block"; } };
+ struct piecewise
+ : organized { std::string name() const { return "value_storage::piecewise"; } };
+ struct disrupted : any { std::string name() const { return "value_storage::disrupted"; } };
+ };
+
+
+// value_browsing:/any/
+// |
+// + -- site_wise_only
+// |
+// + ------- cell_wise
+// | \
+// + -- value_wise \
+// \ \
+// ---- + -- cell_and_value_wise
+
+ struct value_browsing
+ {
+ struct any { protected: any() {} };
+ struct site_wise_only
+ : any { std::string name() const { return "value_browsing::site_wise_only"; } };
+ struct cell_wise
+ : virtual any { std::string name() const { return "value_browsing::cell_wise"; } };
+ struct value_wise
+ : virtual any { std::string name() const { return "value_browsing::value_wise"; } };
+ struct cell_and_value_wise
+ : cell_wise,
+ value_wise
+ { std::string name() const { return "value_browsing::cell_and_value_wise"; } };
+ };
+
+
+// value_io: /any/
+// |
+// + -- read_only
+// |
+// + -- read_write
- struct border
+ struct value_io
{
- struct any {};
- struct none : any { std::string name() const { return "border::none"; } };
- struct some : any { std::string name() const { return "border::some"; } };
- struct stored : some { std::string name() const { return "border::stored"; } };
- struct computed : some { std::string name() const { return "border::computed"; } };
+ struct any { protected: any() {} };
+ struct read_only
+ : any { std::string name() const { return "value_io::read_only"; } };
+ struct read_write
+ : any { std::string name() const { return "value_io::read_write"; } };
};
- struct neighb
- {
- struct any {};
- struct none : any { std::string name() const { return "neighb::none"; } };
- struct some : any { std::string name() const { return "neighb::some"; } };
- };
- struct io
+// localization: /any/
+// |
+// + -- none
+// |
+// + -- space
+// |
+// + -- /grid/
+// |
+// + -- isotropic_grid
+// | |
+// | + -- basic_grid
+// |
+// + -- anisotropic_grid
+
+ struct localization
+ {
+ struct any { protected: any() {} };
+ struct none : any { std::string name() const { return "localization::none"; } };
+ struct space : any { std::string name() const { return "localization::space"; } };
+ struct grid : space { protected: grid() {} };
+ };
+
+// dimension: /any/
+// |
+// + -- none
+// |
+// + -- /some/
+// |
+// + -- one_d
+// |
+// + -- two_d
+// |
+// + -- three_d
+
+ struct dimension
+ {
+ struct any { protected: any() {} };
+ struct none : any { std::string name() const { return "dimension::none"; } };
+ struct some
+ : any { protected: some() {} };
+ struct one_d : some { std::string name() const { return "dimension::one_d"; } };
+ struct two_d : some { std::string name() const { return "dimension::two_d"; } };
+ struct three_d : some { std::string name() const { return "dimension::three_d"; } };
+ };
+
+
+// ext_domain: /any/
+// |
+// + -- none
+// |
+// + -- /some/
+// |
+// + -- fixed
+// | |
+// | + -- infinite
+// |
+// + -- extendable
+
+ struct ext_domain
+ {
+ struct any { protected: any() {} };
+ struct none : any { std::string name() const { return "ext_domain::none"; } };
+ struct some
+ : any { protected: some() {} };
+ struct extendable : some { std::string name() const { return "ext_domain::extendable"; } };
+ struct fixed : some { std::string name() const { return "ext_domain::fixed"; } };
+ struct infinite : fixed { std::string name() const { return "ext_domain::infinite"; } };
+ };
+
+
+// ext_value: /any/
+// |
+// + -- irrelevant
+// |
+// + -- single
+// |
+// + -- multiple
+
+ struct ext_value
+ {
+ struct any { protected: any() {} };
+ struct irrelevant : any { std::string name() const { return "ext_value::irrelevant"; } };
+ struct single : any { std::string name() const { return "ext_value::single"; } };
+ struct multiple : any { std::string name() const { return "ext_value::multiple"; } };
+ };
+
+
+// ext_io: /any/
+// |
+// + -- irrelevant
+// |
+// + -- read_only
+// |
+// + -- read_write
+
+ struct ext_io
{
- struct any {};
- struct read : virtual any {};
- struct write : virtual any {};
+ struct any { protected: any() {} };
struct read_only
- : read { std::string name() const { return "io::read_only"; } };
- struct write_only
- : write { std::string name() const { return "io::write_only"; } };
+ : any { std::string name() const { return "ext_io::read_only"; } };
struct read_write
- : read, write { std::string name() const { return "io::read_write"; } };
+ : any { std::string name() const { return "ext_io::read_write"; } };
};
- struct speed
+
+// kind: /any/
+// |
+// + -- color
+// |
+// + -- gray
+// |
+// + ----------- label
+// | |
+// | +-- named
+// + -- /logic/ |
+// | | |
+// | + -- /mvlogic/
+// | | |
+// | | + -- binary
+// | | |
+// | | + -- ternary
+// | |
+// | + -- fuzzy
+// |
+// + -- data
+// |
+// |
+// + -- /map/
+// |
+// + -- distance
+
+ typedef mln::trait::value::kind kind; // Fetch the 'kind' structure from value traits.
+
+
+// nature: /any/
+// |
+// + -- scalar
+// |
+// + -- vectorial
+// |
+// + -- structed
+// |
+// + -- pointer
+
+ struct nature
+ {
+ struct any { protected: any() {} };
+ struct scalar : any { std::string name() const { return "nature::scalar"; } };
+ struct vectorial : any { std::string name() const { return "nature::vectorial"; } };
+ struct structed : any { std::string name() const { return "nature::structed"; } };
+ struct pointer : any { std::string name() const { return "nature::pointer"; } };
+ };
+
+
+// quant: /any/
+// |
+// + -- low
+// |
+// + -- high
+
+ struct quant
{
- struct any {};
- struct slow : any { std::string name() const { return "speed::slow"; } };
- struct fast : any { std::string name() const { return "speed::fast"; } };
- struct fastest
- : fast { std::string name() const { return "speed::fastest"; } };
+ struct any { protected: any() {} };
+ struct low : any { std::string name() const { return "quant::low"; } };
+ struct high : any { std::string name() const { return "quant::high"; } };
};
Index: mln/trait/image/print.hh
--- mln/trait/image/print.hh (revision 2009)
+++ mln/trait/image/print.hh (working copy)
@@ -68,18 +68,21 @@
mlc_is_a(I, Image)::check();
typedef mln::trait::image_<I> the;
ostr << "{ "
- << typename the::category().name() << ", "
- << typename the::data() .name() << ", "
- << typename the::kind() .name() << ", "
- << typename the::quant() .name() << ", "
- << typename the::value() .name() << ", "
- << typename the::access() .name() << ", "
- << typename the::space() .name() << ", "
- << typename the::size() .name() << ", "
- << typename the::support() .name() << ", "
- << typename the::border() .name() << ", "
- << typename the::io() .name() << ", "
- << typename the::speed() .name() << " }" << std::endl;
+ << typename the::category.name() << ", "
+ << typename the::speed.name() << ", "
+ << typename the::size.name() << ", "
+ << typename the::value_access.name() << ", "
+ << typename the::value_storage.name() << ", "
+ << typename the::value_browsing.name() << ", "
+ << typename the::value_io.name() << ", "
+ << typename the::localization.name() << ", "
+ << typename the::dimension.name() << ", "
+ << typename the::ext_domain.name() << ", "
+ << typename the::ext_value.name() << ", "
+ << typename the::ext_io.name() << ", "
+ << typename the::kind.name() << ", "
+ << typename the::nature.name() << ", "
+ << typename the::quant.name() << " }" << std::endl;
}
template <typename I>
Index: mln/trait/images.hh
--- mln/trait/images.hh (revision 2009)
+++ mln/trait/images.hh (working copy)
@@ -47,6 +47,21 @@
# include <mln/metal/if.hh>
# include <mln/metal/is_const.hh>
+// category
+// speed
+// size
+// value_access
+// value_storage
+// value_browsing
+// value_io
+// localization
+// dimension
+// ext_domain
+// ext_value
+// ext_io
+// kind
+// nature
+// quant
# define mln_trait_image_category(I) typename mln::trait::image_< I >::category
@@ -107,28 +122,30 @@
template <typename I>
struct undefined_image_
{
- typedef undef category; // primary, domain_morpher, value_morpher,
- // or identity_morpher < morpher
-
- // related to I::value
- typedef undef kind; // color, gray, binary < logic < label, data
- typedef undef quant; // low or high
- typedef undef value; // scalar, vectorial, structed, pointer
- // FIXME: Make the difference between homogeneous and heterogeneous vectors...
-
- // related to I::pset
- typedef undef access; // random, browsing
- // FIXME: Wouldn't it be nicer to use metal::int_<DIM>?
- typedef undef space; // one_d, two_d, three_d
- typedef undef size; // huge or regular
- typedef undef support; // irregular, aligned < regular
-
- // global
- typedef undef border; // none, { stored, computed } < some
- typedef undef neighb; // none, some
- typedef undef data; // raw < linear < stored, computed
- typedef undef io; // read_only < read, write_only < write, read_write < both read'n write
- typedef undef speed; // slow, fast, or fastest
+ // misc
+ typedef undef category;
+ typedef undef speed;
+ typedef undef size;
+
+ // value
+ typedef undef value_access;
+ typedef undef value_storage;
+ typedef undef value_browsing;
+ typedef undef value_io;
+
+ // site
+ typedef undef localization;
+ typedef undef dimension;
+
+ // extended domain
+ typedef undef ext_domain;
+ typedef undef ext_value;
+ typedef undef ext_io;
+
+ // data (I::value)
+ typedef undef kind;
+ typedef undef nature;
+ typedef undef quant;
};
@@ -160,31 +177,34 @@
// speed is fast by default (neither "fastest" nor "slow")
typedef trait::image::speed::fast speed;
-
- // neighb is absent by default.
- typedef trait::image::neighb::none neighb;
};
template <typename D, typename T, typename I>
struct default_image_morpher_ : default_image_<T, I>
{
- // value-related => delegation
+ // misc => NO delegation
+ // for category, speed, and size
+
+ // value => delegation
+ typedef typename image_<D>::value_access value_access;
+ typedef typename image_<D>::value_storage value_storage;
+ typedef typename image_<D>::value_browsing value_browsing;
+ typedef typename image_<D>::value_io value_io;
+
+ // site => delegation
+ typedef typename image_<D>::localization localization;
+ typedef typename image_<D>::dimension dimension;
+
+ // extended domain => delegation
+ typedef typename image_<D>::ext_domain ext_domain;
+ typedef typename image_<D>::ext_value ext_value;
+ typedef typename image_<D>::ext_io ext_io;
+
+ // data (I::value) => delegation
+ typedef typename image_<D>::nature nature;
typedef typename image_<D>::kind kind;
typedef typename image_<D>::quant quant;
- typedef typename image_<D>::value value;
-
- // domain-related => delegation
- typedef typename image_<D>::access access;
- typedef typename image_<D>::space space;
- typedef typename image_<D>::size size;
- typedef typename image_<D>::support support;
-
- // mostly global-related => delegation
- typedef typename image_<D>::border border;
- typedef typename image_<D>::neighb neighb;
- typedef typename image_<D>::data data;
- typedef typename image_<D>::io io;
};
1
0
cleanup-2008 2009: New files to keep track of site set and image types status.
by Thierry Geraud 10 Jun '08
by Thierry Geraud 10 Jun '08
10 Jun '08
https://svn.lrde.epita.fr/svn/oln/branches/cleanup-2008/milena
Index: ChangeLog
from Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
New files to keep track of site set and image types status.
* mln/trait/site_set/status.txt: New.
* mln/trait/image/status.txt: New.
* mln/core/internal/site_iterator_base.hh: Remove dead comment.
* mln/core/concept/site_set.hh: Fix (c).
Add a todo.
core/concept/site_set.hh | 6 ++++--
core/internal/site_iterator_base.hh | 2 +-
trait/image/status.txt | 27 +++++++++++++++++++++++++++
trait/site_set/status.txt | 17 +++++++++++++++++
4 files changed, 49 insertions(+), 3 deletions(-)
Index: mln/trait/site_set/status.txt
--- mln/trait/site_set/status.txt (revision 0)
+++ mln/trait/site_set/status.txt (revision 0)
@@ -0,0 +1,17 @@
+ok box_
+KO line2d
+ok p_array
+KO p_array_bb
+KO p_bgraph
+KO p_graph
+KO p_image2d
+KO p_line_graph
+KO p_priority_queue
+KO p_priority_queue_fast
+KO p_priority_queue_fast_with_array
+KO p_queue
+KO p_queue_fast
+KO p_run
+KO p_runs
+KO p_set
+KO pset_if
Index: mln/trait/image/status.txt
--- mln/trait/image/status.txt (revision 0)
+++ mln/trait/image/status.txt (revision 0)
@@ -0,0 +1,27 @@
+KO bgraph_image
+KO cast_image
+KO decorated_image
+KO fi_adaptor
+KO graph_image
+KO hexa
+KO image1d
+KO image2d
+KO image3d
+KO image_if
+KO image_if_interval
+KO image_if_value
+KO interpolated
+KO line_graph_image
+KO mono_obased_rle_image
+KO mono_rle_image
+KO obased_rle_image
+KO plain
+KO pw::image
+KO rle_image
+KO safe
+KO sparse_image
+KO sub_image
+KO t_image
+KO tr_image
+KO translate_image
+KO value_enc_image
Index: mln/core/internal/site_iterator_base.hh
--- mln/core/internal/site_iterator_base.hh (revision 2008)
+++ mln/core/internal/site_iterator_base.hh (working copy)
@@ -52,7 +52,7 @@
proxy_impl< mln_psite(S), E>,
site_impl< false, // Constant access to site / subject.
- mln_site(S), // HOT: typename site_from< >::ret,
+ mln_site(S),
E >
{
Index: mln/core/concept/site_set.hh
--- mln/core/concept/site_set.hh (revision 2008)
+++ mln/core/concept/site_set.hh (working copy)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007 EPITA Research and Development Laboratory
+// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -32,7 +32,9 @@
*
* \brief Definition of the concept of mln::Site_Set.
*
- * \todo Move out the ops.
+ * \todo Rewrite and move out the ops.
+ *
+ * \todo Check optional methods s.a. nsites and bbox.
*/
# include <mln/core/concept/point_site.hh>
1
0