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
March 2008
- 12 participants
- 83 discussions
1803: Fix validity checks on iterators on graph neighborhoods and windows.
by Roland Levillain 25 Mar '08
by Roland Levillain 25 Mar '08
25 Mar '08
https://svn.lrde.epita.fr/svn/oln/trunk/milena
Index: ChangeLog
from Roland Levillain <roland(a)lrde.epita.fr>
Fix validity checks on iterators on graph neighborhoods and windows.
* mln/core/graph_psite.hh
(mln::graph_psite<P>::is_valid_): Set it public.
Rename as...
(mln::graph_psite<P>::is_valid): ...this.
Adjust callers.
* mln/core/graph_neighborhood_piter.hh
(mln::graph_neighborhood_fwd_piter<P>::is_valid):
(mln::graph_neighborhood_bkd_piter<P>::is_valid):
* mln/core/graph_window_piter.hh
(mln::graph_window_fwd_piter<P>::is_valid):
(mln::graph_window_bkd_piter<P>::is_valid):
Use mln::graph_psite<P>::is_valid.
* mln/core/line_graph_psite.hh
(mln::line_graph_psite<P>::is_valid_): Set it public.
Rename as...
(mln::line_graph_psite<P>::is_valid): ...this.
Adjust callers.
* mln/core/line_graph_neighborhood_piter.hh
(mln::line_graph_neighborhood_fwd_piter<P>::is_valid):
(mln::line_graph_neighborhood_bkd_piter<P>::is_valid):
* mln/core/line_graph_window_piter.hh
(mln::line_graph_window_fwd_piter<P>::is_valid):
(mln::line_graph_window_bkd_piter<P>::is_valid):
Use mln::line_graph_psite<P>::is_valid.
graph_neighborhood_piter.hh | 4 ++--
graph_psite.hh | 7 +++----
graph_window_piter.hh | 4 ++--
line_graph_neighborhood_piter.hh | 4 ++--
line_graph_psite.hh | 15 +++++++--------
line_graph_window_piter.hh | 4 ++--
6 files changed, 18 insertions(+), 20 deletions(-)
Index: mln/core/graph_psite.hh
--- mln/core/graph_psite.hh (revision 1802)
+++ mln/core/graph_psite.hh (working copy)
@@ -76,9 +76,8 @@
/// Return the node id of this point site.
util::node_id id() const;
- private:
/// Is this psite valid?
- bool is_valid_() const;
+ bool is_valid() const;
private:
/// The p_graph this point site belongs to.
@@ -137,7 +136,7 @@
template<typename P>
inline
bool
- graph_psite<P>::is_valid_() const
+ graph_psite<P>::is_valid() const
{
return pg_ && id_ < pg_->gr_->nnodes();
}
@@ -163,7 +162,7 @@
mln_coord(P)
graph_psite<P>::operator[](unsigned i) const
{
- mln_assertion(is_valid_());
+ mln_assertion(is_valid());
return to_point()[i];
}
Index: mln/core/graph_neighborhood_piter.hh
--- mln/core/graph_neighborhood_piter.hh (revision 1802)
+++ mln/core/graph_neighborhood_piter.hh (working copy)
@@ -227,7 +227,7 @@
// FIXME: We depend too much on the implementation of util::graph
// here. The util::graph should provide the service to abstract
// these manipulations.
- return id_ < p_ref_.pg().gr_->nnodes();
+ return p_ref_.is_valid() && id_ < p_ref_.pg().gr_->nnodes();
}
template <typename P>
@@ -352,7 +352,7 @@
// FIXME: We depend too much on the implementation of util::graph
// here. The util::graph should provide the service to abstract
// these manipulations.
- return id_ < p_ref_.pg().gr_->nnodes();
+ return p_ref_.is_valid() && id_ < p_ref_.pg().gr_->nnodes();
}
template <typename P>
Index: mln/core/graph_window_piter.hh
--- mln/core/graph_window_piter.hh (revision 1802)
+++ mln/core/graph_window_piter.hh (working copy)
@@ -228,7 +228,7 @@
bool
graph_window_fwd_piter<P>::is_valid() const
{
- return id_ < p_ref_.pg().npoints();
+ return p_ref_.is_valid() && id_ < p_ref_.pg().npoints();
}
template <typename P>
@@ -351,7 +351,7 @@
bool
graph_window_bkd_piter<P>::is_valid() const
{
- return id_ < p_ref_.pg().npoints();
+ return p_ref_.is_valid() && id_ < p_ref_.pg().npoints();
}
template <typename P>
Index: mln/core/line_graph_psite.hh
--- mln/core/line_graph_psite.hh (revision 1802)
+++ mln/core/line_graph_psite.hh (working copy)
@@ -89,9 +89,8 @@
/// Return the id of the second associated vertex.
util::node_id second_id() const;
- private:
/// Is this psite valid?
- bool is_valid_() const;
+ bool is_valid() const;
private:
/// The p_line_graph this point site belongs to.
@@ -179,7 +178,7 @@
template<typename P>
inline
bool
- line_graph_psite<P>::is_valid_() const
+ line_graph_psite<P>::is_valid() const
{
return plg_ && id_ < plg_->gr_->nedges();
}
@@ -206,7 +205,7 @@
mln_coord(P)
line_graph_psite<P>::operator[](unsigned i) const
{
- mln_assertion(is_valid_());
+ mln_assertion(is_valid());
return to_point()[i];
}
@@ -232,7 +231,7 @@
P
line_graph_psite<P>::first() const
{
- mln_assertion(is_valid_());
+ mln_assertion(is_valid());
return plg().gr_->node_data(first_id());
}
@@ -241,7 +240,7 @@
P
line_graph_psite<P>::second() const
{
- mln_assertion(is_valid_());
+ mln_assertion(is_valid());
return plg().gr_->node_data(second_id());
}
@@ -251,7 +250,7 @@
util::node_id
line_graph_psite<P>::first_id() const
{
- mln_assertion(is_valid_());
+ mln_assertion(is_valid());
return plg().gr_->edge(id_).n1();
}
@@ -260,7 +259,7 @@
util::node_id
line_graph_psite<P>::second_id() const
{
- mln_assertion(is_valid_());
+ mln_assertion(is_valid());
return plg().gr_->edge(id_).n2();
}
Index: mln/core/line_graph_neighborhood_piter.hh
--- mln/core/line_graph_neighborhood_piter.hh (revision 1802)
+++ mln/core/line_graph_neighborhood_piter.hh (working copy)
@@ -258,7 +258,7 @@
// FIXME: We depend too much on the implementation of util::graph
// here. The util::graph should provide the service to abstract
// these manipulations.
- return id_ < p_ref_.plg().gr_->nedges();
+ return p_ref_.is_valid() && id_ < p_ref_.plg().gr_->nedges();
}
template <typename P>
@@ -414,7 +414,7 @@
// FIXME: We depend too much on the implementation of util::graph
// here. The util::graph should provide the service to abstract
// these manipulations.
- return id_ < p_ref_.plg().gr_->nedges();
+ return p_ref_.is_valid() && id_ < p_ref_.plg().gr_->nedges();
}
template <typename P>
Index: mln/core/line_graph_window_piter.hh
--- mln/core/line_graph_window_piter.hh (revision 1802)
+++ mln/core/line_graph_window_piter.hh (working copy)
@@ -252,7 +252,7 @@
// FIXME: We depend too much on the implementation of util::graph
// here. The util::graph should provide the service to abstract
// these manipulations.
- return id_ < p_ref_.plg().gr_->nedges();
+ return p_ref_.is_valid() && id_ < p_ref_.plg().gr_->nedges();
}
template <typename P>
@@ -407,7 +407,7 @@
// FIXME: We depend too much on the implementation of util::graph
// here. The util::graph should provide the service to abstract
// these manipulations.
- return id_ < p_ref_.plg().gr_->nedges();
+ return p_ref_.is_valid() && id_ < p_ref_.plg().gr_->nedges();
}
template <typename P>
1
0
1802: Area closing/opening for line graph images based on adjacent vertices.
by Roland Levillain 25 Mar '08
by Roland Levillain 25 Mar '08
25 Mar '08
https://svn.lrde.epita.fr/svn/oln/trunk/milena
Index: ChangeLog
from Roland Levillain <roland(a)lrde.epita.fr>
Area closing/opening for line graph images based on adjacent
vertices.
* mln/core/line_graph_psite.hh
(mln::line_graph_psite<P>::first_id)
(mln::line_graph_psite<P>::second_id):
New methods.
Use them to simplify...
(mln::line_graph_psite<P>::first)
(mln::line_graph_psite<P>::second): ...these ones.
* mln/accu/count_adjacent_vertices.hh: New accumulator.
* mln/morpho/closing_area_on_vertices.hh,
* mln/morpho/opening_area_on_vertices.hh:
New filters.
* mln/morpho/closing_area.hh,
* mln/morpho/opening_area.hh,
* mln/morpho/closing_attribute.hh,
* mln/morpho/opening_attribute.hh:
Remove spurious comments.
* tests/morpho/lena_line_graph_image_wst2.cc: Use
morpho::closing_area_on_vertices instead of morpho::closing.
mln/accu/count_adjacent_vertices.hh | 113 +++++++++++++++++------------
mln/core/line_graph_psite.hh | 32 +++++++-
mln/morpho/closing_area.hh | 5 -
mln/morpho/closing_area_on_vertices.hh | 39 ++++------
mln/morpho/closing_attribute.hh | 5 -
mln/morpho/opening_area.hh | 5 -
mln/morpho/opening_area_on_vertices.hh | 38 ++++-----
mln/morpho/opening_attribute.hh | 5 -
tests/morpho/lena_line_graph_image_wst2.cc | 16 +---
9 files changed, 138 insertions(+), 120 deletions(-)
Index: mln/core/line_graph_psite.hh
--- mln/core/line_graph_psite.hh (revision 1801)
+++ mln/core/line_graph_psite.hh (working copy)
@@ -79,11 +79,16 @@
/// Return the edge id of this point site.
util::edge_id id() const;
- /// Return the first associated point (vertex).
+ /// Return the first associated vertex.
P first() const;
- /// Return the second associated point (vertex).
+ /// Return the second associated vertex.
P second() const;
+ /// Return the id of the first associated vertex.
+ util::node_id first_id() const;
+ /// Return the id of the second associated vertex.
+ util::node_id second_id() const;
+
private:
/// Is this psite valid?
bool is_valid_() const;
@@ -228,7 +233,7 @@
line_graph_psite<P>::first() const
{
mln_assertion(is_valid_());
- return plg().gr_->node_data(plg().gr_->edge(id_).n1());
+ return plg().gr_->node_data(first_id());
}
template<typename P>
@@ -237,7 +242,26 @@
line_graph_psite<P>::second() const
{
mln_assertion(is_valid_());
- return plg().gr_->node_data(plg().gr_->edge(id_).n2());
+ return plg().gr_->node_data(second_id());
+ }
+
+
+ template<typename P>
+ inline
+ util::node_id
+ line_graph_psite<P>::first_id() const
+ {
+ mln_assertion(is_valid_());
+ return plg().gr_->edge(id_).n1();
+ }
+
+ template<typename P>
+ inline
+ util::node_id
+ line_graph_psite<P>::second_id() const
+ {
+ mln_assertion(is_valid_());
+ return plg().gr_->edge(id_).n2();
}
Index: mln/accu/count_adjacent_vertices.hh
--- mln/accu/count_adjacent_vertices.hh (revision 1801)
+++ mln/accu/count_adjacent_vertices.hh (working copy)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007 EPITA Research and Development Laboratory
+// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory (LRDE)
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -25,17 +25,17 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef MLN_ACCU_COUNT_HH
-# define MLN_ACCU_COUNT_HH
+#ifndef MLN_ACCU_COUNT_ADJACENT_VERTICES_HH
+# define MLN_ACCU_COUNT_ADJACENT_VERTICES_HH
-/*! \file mln/accu/count.hh
- *
- * \brief Define an accumulator that counts.
- */
+/// \file mln/accu/count_adjacent_vertices.hh
+/// \brief Define an accumulator that counts the vertices adjacent to a
+/// set of line graph psite.
# include <mln/accu/internal/base.hh>
# include <mln/core/concept/meta_accumulator.hh>
-
+# include <mln/core/line_graph_image.hh>
+# include <mln/util/pix.hh>
namespace mln
{
@@ -43,96 +43,119 @@
namespace accu
{
-
- /*!
- * \brief Generic counter accumulator class.
- *
- * The parameter \a T is the type to be count.
- */
- template <typename T>
- struct count_ : public mln::accu::internal::base_< std::size_t , count_<T> >
+ /// \brief Accumulator class counting the number of vertices
+ /// adjacent to a set of mln::line_graph_psite (i.e., a set of
+ /// edges).
+ ///
+ /// The type to be count is mln::util::pix< mln::line_graph_image<P, V> >
+ /// where \p P and \p V are the parameters of this class.
+ template <typename P, typename V>
+ struct count_adjacent_vertices_
+ : public mln::accu::internal::base_< std::size_t,
+ count_adjacent_vertices_<P, V> >
{
- typedef T argument;
- typedef std::size_t result; // FIXME: Up in Accumulator.
+ typedef mln::util::pix< mln::line_graph_image<P, V> > argument;
- count_();
+ count_adjacent_vertices_();
+ /// Manipulators.
+ /// \{
void init();
- // FIXME : should we add a take() without argument?
- void take(const argument&);
- void take(const count_<T>& other);
+ void take(const argument& arg);
+ void take(const count_adjacent_vertices_<P, V>& other);
- std::size_t to_result() const;
+ /// Force the value of the counter to \a c.
void set_value(std::size_t c);
+ /// \}
+
+ /// Get the value of the accumulator.
+ std::size_t to_result() const;
protected:
+ /// Update the value of the counter.
+ void update_ ();
+ protected:
+ /// The value of the counter.
std::size_t count__;
+ /// The set of adjacent vertices.
+ std::set<util::node_id> vertices_;
};
- /*!
- * \brief Meta accumulator for count.
- */
- struct count : public Meta_Accumulator< count >
+ /// \brief Meta accumulator for count_adjacent_vertices.
+ struct count_adjacent_vertices
+ : public Meta_Accumulator< count_adjacent_vertices >
{
- template <typename T>
+ template <typename P, typename V>
struct with
{
- typedef count_<T> ret;
+ typedef count_adjacent_vertices_<P, V> ret;
};
};
# ifndef MLN_INCLUDE_ONLY
- template <typename T>
+ template <typename P, typename V>
inline
- count_<T>::count_()
+ count_adjacent_vertices_<P, V>::count_adjacent_vertices_()
{
init();
}
- template <typename T>
+ template <typename P, typename V>
inline
void
- count_<T>::init()
+ count_adjacent_vertices_<P, V>::init()
{
- count__ = 0;
+ vertices_.clear();
+ update_();
}
- template <typename T>
+ template <typename P, typename V>
inline
void
- count_<T>::take(const argument&)
+ count_adjacent_vertices_<P, V>::take(const argument& arg)
{
- ++count__;
+ vertices_.insert(arg.p().first_id());
+ vertices_.insert(arg.p().second_id());
+ update_();
}
- template <typename T>
+ template <typename P, typename V>
inline
void
- count_<T>::take(const count_<T>& other)
+ count_adjacent_vertices_<P, V>::take(const count_adjacent_vertices_<P, V>& other)
{
- count__ += other.count__;
+ vertices_.insert (other.vertices_.begin(), other.vertices_.end());
+ update_();
}
- template <typename T>
+ template <typename P, typename V>
inline
std::size_t
- count_<T>::to_result() const
+ count_adjacent_vertices_<P, V>::to_result() const
{
return count__;
}
- template <typename T>
+ template <typename P, typename V>
inline
void
- count_<T>::set_value(std::size_t c)
+ count_adjacent_vertices_<P, V>::set_value(std::size_t c)
{
count__ = c;
}
+ template <typename P, typename V>
+ inline
+ void
+ count_adjacent_vertices_<P, V>::update_()
+ {
+ count__ = vertices_.size();
+ }
+
# endif // ! MLN_INCLUDE_ONLY
} // end of namespace mln::accu
@@ -140,4 +163,4 @@
} // end of namespace mln
-#endif // ! MLN_ACCU_COUNT_HH
+#endif // ! MLN_ACCU_COUNT_ADJACENT_VERTICES_HH
Index: mln/morpho/closing_area_on_vertices.hh
--- mln/morpho/closing_area_on_vertices.hh (revision 1801)
+++ mln/morpho/closing_area_on_vertices.hh (working copy)
@@ -25,16 +25,17 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef MLN_MORPHO_CLOSING_AREA_HH
-# define MLN_MORPHO_CLOSING_AREA_HH
+#ifndef MLN_MORPHO_CLOSING_AREA_ON_VERTICES_HH
+# define MLN_MORPHO_CLOSING_AREA_ON_VERTICES_HH
-/*! \file mln/morpho/closing_area.hh
- *
- * \brief Morphological area closing.
- */
+/// \file mln/morpho/closing_area.hh
+///
+/// \brief Morphological area closing on a line graph image computing
+/// the area in terms of adjacent vertices.
+# include <mln/core/line_graph_image.hh>
# include <mln/morpho/closing_attribute.hh>
-# include <mln/accu/count.hh>
+# include <mln/accu/count_adjacent_vertices.hh>
namespace mln
@@ -43,28 +44,26 @@
namespace morpho
{
- /* FIXME: The neighborhood shall not be passed as argument, but
- bound to the input image. We can also optionnaly provide a
- version of this function for regular-grid-based images where
- the neighborhood is replaced by a (user-provided) window. */
-
- /// Morphological area closing.
- template <typename I, typename N, typename O>
- void closing_area(const Image<I>& input, const Neighborhood<N>& nbh,
+ /// Morphological area closing on a mln::line_graph_image computing
+ /// the area in terms of adjacent vertices.
+ template <typename P, typename V, typename N, typename O>
+ void closing_area_on_vertices(const line_graph_image<P, V>& input,
+ const Neighborhood<N>& nbh,
std::size_t lambda, Image<O>& output);
# ifndef MLN_INCLUDE_ONLY
- template <typename I, typename N, typename O>
+ template <typename P, typename V, typename N, typename O>
inline
- void closing_area(const Image<I>& input, const Neighborhood<N>& nbh,
+ void closing_area_on_vertices(const line_graph_image<P, V>& input,
+ const Neighborhood<N>& nbh,
std::size_t lambda, Image<O>& output)
{
mln_precondition(exact(output).domain() == exact(input).domain());
- typedef util::pix<I> pix_t;
+ typedef accu::count_adjacent_vertices_<P, V> attribute_t;
// FIXME: Change sig of closing_attribute!
- closing_attribute< accu::count_<pix_t> >(input, nbh, lambda, output);
+ closing_attribute<attribute_t>(input, nbh, lambda, output);
}
# endif // ! MLN_INCLUDE_ONLY
@@ -74,4 +73,4 @@
} // end of namespace mln
-#endif // ! MLN_MORPHO_CLOSING_AREA_HH
+#endif // ! MLN_MORPHO_CLOSING_AREA_ON_VERTICES_HH
Index: mln/morpho/opening_area_on_vertices.hh
--- mln/morpho/opening_area_on_vertices.hh (revision 1801)
+++ mln/morpho/opening_area_on_vertices.hh (working copy)
@@ -25,16 +25,16 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef MLN_MORPHO_OPENING_AREA_HH
-# define MLN_MORPHO_OPENING_AREA_HH
+#ifndef MLN_MORPHO_OPENING_AREA_ON_VERTICES_HH
+# define MLN_MORPHO_OPENING_AREA_ON_VERTICES_HH
-/*! \file mln/morpho/opening_area.hh
- *
- * \brief Morphological area opening.
- */
+/// \file mln/morpho/opening_area_on_vertices.hh
+/// \brief Morphological area opening on a line graph image computing
+/// the area in terms of adjacent vertices.
+# include <mln/core/line_graph_image.hh>
# include <mln/morpho/opening_attribute.hh>
-# include <mln/accu/count.hh>
+# include <mln/accu/count_adjacent_vertices.hh>
namespace mln
@@ -43,28 +43,26 @@
namespace morpho
{
- /* FIXME: The neighborhood shall not be passed as argument, but
- bound to the input image. We can also optionnaly provide a
- version of this function for regular-grid-based images where
- the neighborhood is replaced by a (user-provided) window. */
-
- /// Morphological area opening.
- template <typename I, typename N, typename O>
- void opening_area(const Image<I>& input, const Neighborhood<N>& nbh,
+ /// Morphological area opening on a mln::line_graph_image computing
+ /// the area in terms of adjacent vertices.
+ template <typename P, typename V, typename N, typename O>
+ void opening_area_on_vertices(const line_graph_image<P, V>& input,
+ const Neighborhood<N>& nbh,
std::size_t lambda, Image<O>& output);
# ifndef MLN_INCLUDE_ONLY
- template <typename I, typename N, typename O>
+ template <typename P, typename V, typename N, typename O>
inline
- void opening_area(const Image<I>& input, const Neighborhood<N>& nbh,
+ void opening_area_on_vertices(const line_graph_image<P, V>& input,
+ const Neighborhood<N>& nbh,
std::size_t lambda, Image<O>& output)
{
mln_precondition(exact(output).domain() == exact(input).domain());
- typedef util::pix<I> pix_t;
+ typedef accu::count_adjacent_vertices_<P, V> attribute_t;
// FIXME: Change sig of opening_attribute!
- opening_attribute< accu::count_<pix_t> >(input, nbh, lambda, output);
+ opening_attribute<attribute_t>(input, nbh, lambda, output);
}
# endif // ! MLN_INCLUDE_ONLY
@@ -74,4 +72,4 @@
} // end of namespace mln
-#endif // ! MLN_MORPHO_OPENING_AREA_HH
+#endif // ! MLN_MORPHO_OPENING_AREA_ON_VERTICES_HH
Index: mln/morpho/closing_area.hh
--- mln/morpho/closing_area.hh (revision 1801)
+++ mln/morpho/closing_area.hh (working copy)
@@ -43,11 +43,6 @@
namespace morpho
{
- /* FIXME: The neighborhood shall not be passed as argument, but
- bound to the input image. We can also optionnaly provide a
- version of this function for regular-grid-based images where
- the neighborhood is replaced by a (user-provided) window. */
-
/// Morphological area closing.
template <typename I, typename N, typename O>
void closing_area(const Image<I>& input, const Neighborhood<N>& nbh,
Index: mln/morpho/opening_area.hh
--- mln/morpho/opening_area.hh (revision 1801)
+++ mln/morpho/opening_area.hh (working copy)
@@ -43,11 +43,6 @@
namespace morpho
{
- /* FIXME: The neighborhood shall not be passed as argument, but
- bound to the input image. We can also optionnaly provide a
- version of this function for regular-grid-based images where
- the neighborhood is replaced by a (user-provided) window. */
-
/// Morphological area opening.
template <typename I, typename N, typename O>
void opening_area(const Image<I>& input, const Neighborhood<N>& nbh,
Index: mln/morpho/closing_attribute.hh
--- mln/morpho/closing_attribute.hh (revision 1801)
+++ mln/morpho/closing_attribute.hh (working copy)
@@ -45,11 +45,6 @@
namespace morpho
{
- /* FIXME: The neighborhood shall not be passed as argument, but
- bound to the input image. We can also optionnaly provide a
- version of this function for regular-grid-based images where
- the neighborhood is replaced by a (user-provided) window. */
-
/// Morphological attribute closing.
template <typename A,
typename I, typename N, typename O>
Index: mln/morpho/opening_attribute.hh
--- mln/morpho/opening_attribute.hh (revision 1801)
+++ mln/morpho/opening_attribute.hh (working copy)
@@ -45,11 +45,6 @@
namespace morpho
{
- /* FIXME: The neighborhood shall not be passed as argument, but
- bound to the input image. We can also optionnaly provide a
- version of this function for regular-grid-based images where
- the neighborhood is replaced by a (user-provided) window. */
-
/// Morphological attribute opening.
template <typename A,
typename I, typename N, typename O>
Index: tests/morpho/lena_line_graph_image_wst2.cc
--- tests/morpho/lena_line_graph_image_wst2.cc (revision 1801)
+++ tests/morpho/lena_line_graph_image_wst2.cc (working copy)
@@ -42,9 +42,9 @@
between the values on the nodes adjacent to the edge, so as to
create a (norm of the gradient) ``between the pixels'' of the
input image;
- \li (insert an minima-killer pass here, as soon as it works on
- graph-based images);
- \li perform a WST on the line graph image;
+ \li reduce the number of minima using an area opening (computing the
+ area using the vertices, not the edges);
+ \li perform a WST on this simplified line graph image;
\li reduce the quantification of the result of the WST;
\li create an 2-D, color output image with height and width double
the size the original one, and copy the data of the input image
@@ -63,7 +63,7 @@
#include <mln/core/line_graph_neighborhood_piter.hh>
#include <mln/morpho/line_gradient.hh>
-#include <mln/morpho/closing_area.hh>
+#include <mln/morpho/closing_area_on_vertices.hh>
#include <mln/morpho/meyer_wst.hh>
#include <mln/level/stretch.hh>
@@ -114,13 +114,7 @@
nbh_t nbh;
ima_t closed_lg_ima (lg_ima.domain());
- /* FIXME: We should change the attribute closing performed here;
- instead of computing the area using the data on the lines
- (edges), whe should use the data on the pixels (vertices).
-
- The best way is probably to create another attribute-functor and
- use the algebraic_union_find canvas. */
- morpho::closing_area(lg_ima, nbh, 20, closed_lg_ima);
+ morpho::closing_area_on_vertices(lg_ima, nbh, 20, closed_lg_ima);
/*------.
| WST. |
1
0
https://svn.lrde.epita.fr/svn/oln/trunk/milena
Index: ChangeLog
from Roland Levillain <roland(a)lrde.epita.fr>
Line gradient computation.
* tests/morpho/lena_line_graph_image_wst1.cc: Fix comments.
* tests/morpho/lena_line_graph_image_wst2.cc: Fix the
initialization of the watershed image.
Reify and move the line gradient computation...
* mln/morpho/line_gradient.hh: ...here (new file).
mln/morpho/line_gradient.hh | 122 +++++++++++++++++++++++++++++
tests/morpho/lena_line_graph_image_wst1.cc | 9 --
tests/morpho/lena_line_graph_image_wst2.cc | 63 +-------------
3 files changed, 133 insertions(+), 61 deletions(-)
Index: tests/morpho/lena_line_graph_image_wst1.cc
--- tests/morpho/lena_line_graph_image_wst1.cc (revision 1800)
+++ tests/morpho/lena_line_graph_image_wst1.cc (working copy)
@@ -90,11 +90,8 @@
image2d<input_val_t> input;
io::pgm::load(input, MLN_IMG_DIR "/tiny.pgm");
- /* FIXME: Don't compute a gradient on the image2d input. Instead,
- have the values of the line graph image /behaves/ as the gradient
- of the input, i.e., edges should hold the absolute difference
- between gray levels.
- */
+ // In this test, the gradient is directly computed on the input
+ // image, not on the edges of the line graph image.
image2d<input_val_t> gradient =
morpho::gradient (input, convert::to_window(c4()));
@@ -126,7 +123,7 @@
g.add_node (p);
node_values.push_back (work(p));
/* FIXME: ``Guessing'' the id of the point just being inserted
- is bad. utill:graph<N,E>::add_node should return this
+ is bad. util:graph<N,E>::add_node should return this
id. */
points[p] = id;
++id;
Index: tests/morpho/lena_line_graph_image_wst2.cc
--- tests/morpho/lena_line_graph_image_wst2.cc (revision 1800)
+++ tests/morpho/lena_line_graph_image_wst2.cc (working copy)
@@ -62,7 +62,7 @@
#include <mln/core/line_graph_elt_neighborhood.hh>
#include <mln/core/line_graph_neighborhood_piter.hh>
-#include <mln/morpho/gradient.hh>
+#include <mln/morpho/line_gradient.hh>
#include <mln/morpho/closing_area.hh>
#include <mln/morpho/meyer_wst.hh>
#include <mln/level/stretch.hh>
@@ -98,57 +98,13 @@
image2d<input_val_t> input;
io::pgm::load(input, MLN_IMG_DIR "/small.pgm");
- /*-------------.
- | Line graph. |
- `-------------*/
-
- // FIXME: Inlined conversion, to be reifed into a routine.
-
- util::graph<point2d> g;
-
- // Points.
- /* FIXME: The need for such a structure during the conversion
- exhibits the lack of a service from util::graph (or a another,
- missing tool) regarding the retrieval of nodes' ids from
- points. */
- std::map<point2d, util::node_id> points;
- util::node_id id = 0;
-
- // Nodes.
- std::vector<input_val_t> node_values;
- mln_fwd_piter_(image2d<input_val_t>) p(input.domain());
- for_all (p)
- {
- g.add_node (p);
- node_values.push_back (input(p));
- /* FIXME: ``Guessing'' the id of the point just being inserted
- is bad. utill:graph<N,E>::add_node should return this
- id. */
- points[p] = id;
- ++id;
- }
-
- // Edges.
- window2d next_c4_win;
- next_c4_win.insert(0, 1).insert(1, 0);
- std::vector<input_val_t> edge_values;
- mln_fwd_qiter_(window2d) q(next_c4_win, p);
- for_all (p)
- for_all (q)
- if (input.has(q))
- {
- g.add_edge(points[p], points[q]);
- // The computed value is a kind of norm of the gradient
- // bewteen P and Q.
- edge_values.push_back(math::abs(input(p) - input(q)));
- }
-
- // Line graph point set.
- p_line_graph<point2d> plg(g);
+ /*----------------.
+ | Line gradient. |
+ `----------------*/
// Line graph image.
typedef line_graph_image<point2d, input_val_t> ima_t;
- ima_t lg_ima(plg, node_values, edge_values);
+ ima_t lg_ima = morpho::line_gradient(input);
/*-----------------.
| Simplification. |
@@ -180,10 +136,8 @@
// Reduce the value set to 8-bit.
typedef int_u8 wst_val_t;
typedef line_graph_image<point2d, wst_val_t> wst_ima_t;
- // FIXME: Initializations should not be that complicated.
- wst_ima_t wshed (plg,
- std::vector<wst_val_t>(node_values.size()),
- std::vector<wst_val_t>(edge_values.size()));
+ wst_ima_t wshed;
+ initialize(wshed, wshed_full);
level::stretch(wshed_full, wshed);
/*---------.
@@ -202,7 +156,7 @@
input.domain().pmax()[1] * 2);
output_t output(box2d(output_pmin, output_pmax));
level::fill(output, literal::black);
- // Reuse the piter on INPUT.
+ mln_fwd_piter_(image2d<input_val_t>) p(input.domain());
for_all(p)
{
// Equivalent of P in OUTPUT.
@@ -214,7 +168,6 @@
}
// Interpolate missing points in OUTPUT.
mln_piter_(output_t) p_out(output.domain());
-// mln_niter_(neighb2d) n_out(c4(), p_out);
for_all(p_out)
{
// Process points on even rows and odd columns
Index: mln/morpho/line_gradient.hh
--- mln/morpho/line_gradient.hh (revision 0)
+++ mln/morpho/line_gradient.hh (revision 0)
@@ -0,0 +1,122 @@
+// 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_MORPHO_LINE_GRADIENT_HH
+# define MLN_MORPHO_LINE_GRADIENT_HH
+
+/// \file mln/morpho/line_gradient.hh
+/// \brief Conversions to mln::line_graph_image.
+
+# include <map>
+# include <vector>
+
+# include <mln/core/image2d.hh>
+# include <mln/core/line_graph_image.hh>
+
+// FIXME: Generalize to other (input) images as well (image1d,
+// image3d, etc.).
+
+namespace mln
+{
+
+ namespace morpho
+ {
+
+ /// \brief Create a line graph image representing the gradient
+ /// norm of a mln::image2d.
+ /* FIXME: Currently, the adjacency is set to 4-c and cannot be
+ changed. */
+ template <typename T>
+ mln::line_graph_image<mln::point2d, T>
+ line_gradient(const mln::image2d<T>& ima);
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename T>
+ mln::line_graph_image<mln::point2d, T>
+ line_gradient(const mln::image2d<T>& ima)
+ {
+ // FIXME: Precondition: Ensure the image is scalar.
+ typedef T value_t;
+
+ util::graph<mln::point2d> g;
+
+ // Points.
+ /* FIXME: The need for such a structure during the conversion
+ exhibits the lack of a service from util::graph (or a another,
+ missing tool) regarding the retrieval of nodes' ids from
+ points. */
+ std::map<mln::point2d, util::node_id> points;
+ util::node_id id = 0;
+
+ // Nodes.
+ std::vector<value_t> node_values;
+ mln_fwd_piter(image2d<value_t>) p(ima.domain());
+ for_all (p)
+ {
+ g.add_node (p);
+ node_values.push_back (ima(p));
+ /* FIXME: ``Guessing'' the id of the point just being inserted
+ is bad. util:graph<N,E>::add_node should return this
+ id. */
+ points[p] = id;
+ ++id;
+ }
+
+ // Edges.
+ // FIXME: The creation of this window should be generic.
+ window2d next_c4_win;
+ next_c4_win.insert(0, 1).insert(1, 0);
+ std::vector<value_t> edge_values;
+ mln_fwd_qiter_(window2d) q(next_c4_win, p);
+ for_all (p)
+ for_all (q)
+ if (ima.has(q))
+ {
+ g.add_edge(points[p], points[q]);
+ // The computed value is a norm of the gradient between P and Q.
+ edge_values.push_back(math::abs(ima(p) - ima(q)));
+ }
+
+ // Line graph point set.
+ p_line_graph<mln::point2d> plg(g);
+
+ // Line graph image.
+ typedef line_graph_image<mln::point2d, value_t> ima_t;
+ ima_t lg_ima(plg, node_values, edge_values);
+ return lg_ima;
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::morpho
+
+} // end of namespace mln
+
+
+#endif // ! MLN_MORPHO_LINE_GRADIENT_HH
1
0
25 Mar '08
https://svn.lrde.epita.fr/svn/oln/trunk/milena
Index: ChangeLog
from Roland Levillain <roland(a)lrde.epita.fr>
Fix some memory management problems w.r.t. graph-based images.
* mln/core/p_graph.hh (mln::p_graph<P>::gr_): Handle the
underlying graph as a tracked pointer.
(mln::p_graph<P>::p_graph(const graph&))
(mln::p_graph<P>::nnodes)
(mln::p_graph<P>::point_from_id)
(mln::p_graph<P>::node1, mln::p_graph<P>::node2)
(mln::p_graph<P>::has(const psite&))
(mln::p_graph<P>::adjacent_or_equal)
(mln::operator==(const p_graph<P>&, const p_graph<P>&)):
Adjust.
* mln/core/graph_image.hh
(mln::internal::data_< graph_image<P, V> >::pg_): Handle the
p_graph by copy, as the tracked pointer takes care of the
memory management.
(mln::graph_image<P, V>::operator()(const graph_psite<P>&)):
Adjust operators.
* mln/core/graph_psite.hh,
* mln/core/graph_window_piter.hh:
Adjust.
* mln/core/graph_neighborhood_piter.hh: Likewise.
(mln::graph_neighborhood_fwd_piter<P>::adjacent_or_equal_to_p_ref_)
(mln::graph_neighborhood_bkd_piter<P>::adjacent_or_equal_to_p_ref_):
Simplify using mln::p_graph<P>::adjacent_or_equal.
* mln/core/p_line_graph.hh (mln::p_line_graph<P>::gr_): Handle the
underlying graph as a tracked pointer.
(mln::p_line_graph<P>::p_line_graph(const graph&))
(mln::p_line_graph<P>::nnodes, mln::p_line_graph<P>::nedges)
(mln::p_line_graph<P>::has(const psite&))
(mln::operator==(const p_line_graph<P>&, const p_line_graph<P>&)):
Adjust.
* mln/core/line_graph_image.hh
(mln::internal::data_< line_graph_image<P, V> >::plg_): Handle the
p_line_graph by copy, as the tracked pointer takes care of the
memory management.
(mln::line_graph_image<P, V>::operator()(const line_graph_psite<P>&)):
Adjust operators.
* mln/core/line_graph_psite.hh,
* mln/core/line_graph_neighborhood_piter.hh,
* mln/core/line_graph_window_piter.hh:
Adjust.
graph_image.hh | 11 ++-----
graph_neighborhood_piter.hh | 58 ++++-----------------------------------
graph_psite.hh | 2 -
graph_window_piter.hh | 2 -
line_graph_image.hh | 11 ++-----
line_graph_neighborhood_piter.hh | 32 +++++++++++----------
line_graph_psite.hh | 6 ++--
line_graph_window_piter.hh | 32 +++++++++++----------
p_graph.hh | 42 ++++++++++++++++------------
p_line_graph.hh | 30 ++++++++++++--------
10 files changed, 94 insertions(+), 132 deletions(-)
Index: mln/core/p_graph.hh
--- mln/core/p_graph.hh (revision 1799)
+++ mln/core/p_graph.hh (working copy)
@@ -31,6 +31,7 @@
# include <mln/core/concept/point_site.hh>
# include <mln/core/internal/point_set_base.hh>
# include <mln/accu/bbox.hh>
+# include <mln/util/tracked_ptr.hh>
# include <mln/util/graph.hh>
# include <mln/core/graph_psite.hh>
# include <mln/core/p_graph_piter.hh>
@@ -50,8 +51,13 @@
{
typedef util::graph<P> graph;
- /// Construct a graph psite set from a graph of points.
- p_graph (graph& gr);
+ /// \brief Construct a graph psite set from a graph of points.
+ ///
+ /// \param gr The graph upon which the graph psite set is built.
+ ///
+ /// \a gr is \em copied internally, so that the graph psite set is
+ /// still valid after the initial graph has been removed.
+ p_graph (const graph& gr);
/// Point_Site associated type.
typedef graph_psite<P> psite;
@@ -102,7 +108,7 @@
// FIXME: Should be private.
public:
- graph gr_;
+ util::tracked_ptr<graph> gr_;
// FIXME: (Roland) Is it really useful/needed?
/* 2007-12-19: It seems so, since graph_image must implement a method
named bbox(). Now the question is: should each image type have a
@@ -114,8 +120,8 @@
/// \brief Comparison between two mln::p_graph's.
///
- /// Two mln::p_graph's are considered equal if they have the
- /// same address.
+ /// Two mln::p_graph's are considered equal if they share the
+ /// same graph.
template <typename P>
bool
operator==(const p_graph<P>& lhs, const p_graph<P>& rhs);
@@ -125,14 +131,14 @@
template<typename P>
inline
- p_graph<P>::p_graph (util::graph<P>& gr)
- : gr_ (gr)
+ p_graph<P>::p_graph (const util::graph<P>& gr)
+ : gr_ (new util::graph<P>(gr))
{
// FIXME: Warning: if the underlying graph is updated later, this
// won't be taken into account by this p_graph!
accu::bbox<P> a;
for (unsigned i = 0; i < npoints(); ++i)
- a.take(gr_.node_data(i));
+ a.take(gr_->node_data(i));
bb_ = a.to_result();
}
@@ -149,7 +155,7 @@
std::size_t
p_graph<P>::nnodes() const
{
- return this->gr_.nnodes();
+ return this->gr_->nnodes();
}
template<typename P>
@@ -157,7 +163,7 @@
std::size_t
p_graph<P>::nedges() const
{
- return this->gr_.nedges();
+ return this->gr_->nedges();
}
template<typename P>
@@ -177,28 +183,28 @@
// Check whether P is compatible with this psite set.
(&p.pg() == this) &&
// Check that the node id of P belongs to the range of valid node ids.
- (p.id() < gr_.nnodes());
+ (p.id() < gr_->nnodes());
}
template <typename P>
const P&
p_graph<P>::point_from_id(const util::node_id& id) const
{
- return this->gr_.node_data(id);
+ return this->gr_->node_data(id);
}
template <typename P>
P&
p_graph<P>::point_from_id(const util::node_id& id)
{
- return this->gr_.node_data(id);
+ return this->gr_->node_data(id);
}
template <typename P>
const P&
p_graph<P>::node1(const util::edge_id& e) const
{
- util::node_id n1 = this->gr_.edge(e).n1();
+ util::node_id n1 = this->gr_->edge(e).n1();
return this->point_from_id(n1);
}
@@ -206,7 +212,7 @@
const P&
p_graph<P>::node2(const util::edge_id& e) const
{
- util::node_id n2 = this->gr_.edge(e).n2();
+ util::node_id n2 = this->gr_->edge(e).n2();
return this->point_from_id(n2);
}
@@ -225,7 +231,7 @@
p_graph<P>::adjacent_or_equal(const util::node_id& lhs,
const util::node_id& rhs) const
{
- // FIXME: Likewise, this is inefficient.
+ // FIXME: This is inefficient.
assert (lhs < this->npoints());
assert (rhs < this->npoints());
@@ -235,7 +241,7 @@
// Check whether the iterator is among the neighbors of P_REF_.
typedef std::vector<util::node_id> adjacency_type;
- const adjacency_type& lhs_neighbs = gr_.nodes()[lhs]->edges;
+ const adjacency_type& lhs_neighbs = gr_->nodes()[lhs]->edges;
adjacency_type::const_iterator j =
std::find (lhs_neighbs.begin(), lhs_neighbs.end(), rhs);
@@ -264,7 +270,7 @@
bool
operator==(const p_graph<P>& lhs, const p_graph<P>& rhs)
{
- return &lhs == &rhs;
+ return lhs.gr_.ptr_ == rhs.gr_.ptr_;
}
# endif // ! MLN_INCLUDE_ONLY
Index: mln/core/graph_image.hh
--- mln/core/graph_image.hh (revision 1799)
+++ mln/core/graph_image.hh (working copy)
@@ -56,12 +56,7 @@
data_(const p_graph<P>& g, const std::vector<V>& val);
std::vector<V> val_;
- /* The graph point set is handled by address, so that we can
- check the compatibility of images w.r.t. to their point
- sites. We could use a safer (and more complex) facility to
- ensure (memory) equality of line graph point sets, but using
- addresses is simple and efficient enough for the moment. */
- const p_graph<P>& pg_;
+ const p_graph<P> pg_;
};
} // end of namespace mln::internal
@@ -239,7 +234,7 @@
typename graph_image<P, V>::rvalue
graph_image<P, V>::operator()(const graph_psite<P>& p) const
{
- mln_precondition(&p.pg() == &this->data_->pg_);
+ mln_precondition(p.pg() == this->data_->pg_);
mln_precondition(p.id() < this->data_->val_.size());
return this->data_->val_[p.id()];
}
@@ -249,7 +244,7 @@
typename graph_image<P, V>::lvalue
graph_image<P, V>::operator()(const graph_psite<P>& p)
{
- mln_precondition(&p.pg() == &this->data_->pg_);
+ mln_precondition(p.pg() == this->data_->pg_);
mln_precondition(p.id() < this->data_->val_.size());
return this->data_->val_[p.id()];
}
Index: mln/core/graph_psite.hh
--- mln/core/graph_psite.hh (revision 1799)
+++ mln/core/graph_psite.hh (working copy)
@@ -139,7 +139,7 @@
bool
graph_psite<P>::is_valid_() const
{
- return pg_ && id_ < pg_->gr_.nnodes();
+ return pg_ && id_ < pg_->gr_->nnodes();
}
template<typename P>
Index: mln/core/graph_window_piter.hh
--- mln/core/graph_window_piter.hh (revision 1799)
+++ mln/core/graph_window_piter.hh (working copy)
@@ -367,7 +367,7 @@
void
graph_window_bkd_piter<P>::start()
{
- id_ = p_ref_.plg().gr_.nnodes() - 1;
+ id_ = p_ref_.plg().gr_->nnodes() - 1;
if (!adjacent_or_equal_to_p_ref_())
next_();
/* FIXME: This is redundant with the end of next_(), but we might
Index: mln/core/graph_neighborhood_piter.hh
--- mln/core/graph_neighborhood_piter.hh (revision 1799)
+++ mln/core/graph_neighborhood_piter.hh (working copy)
@@ -227,7 +227,7 @@
// FIXME: We depend too much on the implementation of util::graph
// here. The util::graph should provide the service to abstract
// these manipulations.
- return id_ < p_ref_.pg().gr_.nnodes();
+ return id_ < p_ref_.pg().gr_->nnodes();
}
template <typename P>
@@ -277,29 +277,7 @@
bool
graph_neighborhood_fwd_piter<P>::adjacent_or_equal_to_p_ref_() const
{
- // FIXME: Likewise, this is inefficient.
-
- // Check wether the iterator points to P_REF_.
- if (id_ == p_ref_.id())
- return true;
-
- // Check whether the iterator is among the neighbors of P_REF_.
- {
- // Paranoid assertion.
- assert (p_ref_.id() < p_ref_.pg().gr_.nnodes());
- // FIXME: This is too low-level. Yet another service the graph
- // should provide.
- typedef std::vector<util::node_id> adjacency_type;
- const adjacency_type& p_ref_neighbs =
- p_ref_.pg().gr_.nodes()[p_ref_.id()]->edges;
- adjacency_type::const_iterator j =
- std::find (p_ref_neighbs.begin(), p_ref_neighbs.end(), id_);
- if (j != p_ref_neighbs.end())
- return true;
- }
-
- // Otherwise, the iterator is not adjacent to P_REF_.
- return false;
+ return p_ref_.pg().adjacent_or_equal(p_ref_.id(), id_);
}
template <typename P>
@@ -310,7 +288,7 @@
// Update psite_.
psite_ = graph_psite<P>(p_ref_.pg(), id_);
// Update p_.
- p_ = p_ref_.pg().gr_.node_data(id_);
+ p_ = p_ref_.pg().gr_->node_data(id_);
}
template <typename P>
@@ -374,7 +352,7 @@
// FIXME: We depend too much on the implementation of util::graph
// here. The util::graph should provide the service to abstract
// these manipulations.
- return id_ < p_ref_.pg().gr_.nnodes();
+ return id_ < p_ref_.pg().gr_->nnodes();
}
template <typename P>
@@ -390,7 +368,7 @@
void
graph_neighborhood_bkd_piter<P>::start()
{
- id_ = p_ref_.plg().gr_.nnodes() - 1;
+ id_ = p_ref_.plg().gr_->nnodes() - 1;
if (!adjacent_or_equal_to_p_ref_())
next_();
/* FIXME: This is redundant with the end of next_(), but we might
@@ -424,29 +402,7 @@
bool
graph_neighborhood_bkd_piter<P>::adjacent_or_equal_to_p_ref_() const
{
- // FIXME: Likewise, this is inefficient.
-
- // Check wether the iterator points to P_REF_.
- if (id_ == p_ref_.id())
- return true;
-
- // Check whether the iterator is among the neighbors of P_REF_.
- {
- // Paranoid assertion.
- assert (p_ref_.id() < p_ref_.pg().gr_.nnodes());
- // FIXME: This is too low-level. Yet another service the graph
- // should provide.
- typedef std::vector<util::node_id> adjacency_type;
- const adjacency_type& p_ref_neighbs =
- p_ref_.pg().gr_.nodes()[p_ref_.id()]->edges;
- adjacency_type::const_iterator j =
- std::find (p_ref_neighbs.begin(), p_ref_neighbs.end(), id_);
- if (j != p_ref_neighbs.end())
- return true;
- }
-
- // Otherwise, the iterator is not adjacent to P_REF_.
- return false;
+ return p_ref_.pg().adjacent_or_equal(p_ref_.id(), id_);
}
template <typename P>
@@ -457,7 +413,7 @@
// Update psite_.
psite_ = graph_psite<P>(p_ref_.pg(), id_);
// Update p_.
- p_ = p_ref_.pg().gr_.node_data(id_);
+ p_ = p_ref_.pg().gr_->node_data(id_);
}
template <typename P>
Index: mln/core/p_line_graph.hh
--- mln/core/p_line_graph.hh (revision 1799)
+++ mln/core/p_line_graph.hh (working copy)
@@ -32,6 +32,7 @@
# include <mln/core/internal/point_set_base.hh>
# include <mln/accu/bbox.hh>
# include <mln/util/graph.hh>
+# include <mln/util/tracked_ptr.hh>
# include <mln/core/line_graph_psite.hh>
# include <mln/core/p_line_graph_piter.hh>
@@ -54,8 +55,13 @@
{
typedef util::graph<P> graph;
- /// Construct a line graph psite set from a graph of points.
- p_line_graph (graph& gr);
+ /// \brief Construct a line graph psite set from a graph of points.
+ ///
+ /// \param gr The graph upon which the line graph psite set is built.
+ ///
+ /// \a gr is \em copied internally, so that the line graph psite
+ /// set is still valid after the initial graph has been removed.
+ p_line_graph (const graph& gr);
/// Point_Site associated type.
typedef line_graph_psite<P> psite;
@@ -82,7 +88,7 @@
bool has(const psite& p) const;
// FIXME: Should be private.
- graph gr_;
+ util::tracked_ptr<graph> gr_;
// FIXME: (Roland) Is it really useful/needed?
/* 2007-12-19: It seems so, since graph_image must implement a
method named bbox(). Now the question is: should each image
@@ -93,8 +99,8 @@
/// \brief Comparison between two mln::p_line_graph's.
///
- /// Two mln::p_line_graph's are considered equal if they have the
- /// same address.
+ /// Two mln::p_line_graph's are considered equal if they share the
+ /// same graph.
template <typename P>
bool
operator==(const p_line_graph<P>& lhs, const p_line_graph<P>& rhs);
@@ -104,14 +110,14 @@
template<typename P>
inline
- p_line_graph<P>::p_line_graph (util::graph<P>& gr)
- : gr_ (gr)
+ p_line_graph<P>::p_line_graph (const util::graph<P>& gr)
+ : gr_ (new util::graph<P>(gr))
{
// FIXME: Warning: if the underlying graph is updated later, this
// won't be taken into account by this p_line_graph!
accu::bbox<P> a;
for (unsigned i = 0; i < nnodes(); ++i)
- a.take(gr_.node_data(i));
+ a.take(gr_->node_data(i));
bb_ = a.to_result();
}
@@ -128,7 +134,7 @@
std::size_t
p_line_graph<P>::nnodes() const
{
- return this->gr_.nnodes();
+ return this->gr_->nnodes();
}
template<typename P>
@@ -136,7 +142,7 @@
std::size_t
p_line_graph<P>::nedges() const
{
- return this->gr_.nedges();
+ return this->gr_->nedges();
}
template<typename P>
@@ -156,7 +162,7 @@
// Check whether P is compatible with this psite set.
(&p.plg() == this) &&
// Check that the edge id of P belongs to the range of valid edge ids.
- (p.id() < gr_.nedges());
+ (p.id() < gr_->nedges());
}
@@ -164,7 +170,7 @@
bool
operator==(const p_line_graph<P>& lhs, const p_line_graph<P>& rhs)
{
- return &lhs == &rhs;
+ return lhs.gr_.ptr_ == rhs.gr_.ptr_;
}
# endif // ! MLN_INCLUDE_ONLY
Index: mln/core/line_graph_image.hh
--- mln/core/line_graph_image.hh (revision 1799)
+++ mln/core/line_graph_image.hh (working copy)
@@ -72,12 +72,7 @@
std::vector<V> node_val_;
std::vector<V> edge_val_;
- /* The line graph point set is handled by address, so that we
- can check the compatibility of images w.r.t. to their point
- sites. We could use a safer (and more complex) facility to
- ensure (memory) equality of line graph point sets, but using
- addresses is simple and efficient enough for the moment. */
- const p_line_graph<P>& plg_;
+ const p_line_graph<P> plg_;
};
} // end of namespace mln::internal
@@ -273,7 +268,7 @@
typename line_graph_image<P, V>::rvalue
line_graph_image<P, V>::operator()(const line_graph_psite<P>& p) const
{
- mln_precondition(&p.plg() == &this->data_->plg_);
+ mln_precondition(p.plg() == this->data_->plg_);
mln_precondition(p.id() < this->data_->edge_val_.size());
return this->data_->edge_val_[p.id()];
}
@@ -283,7 +278,7 @@
typename line_graph_image<P, V>::lvalue
line_graph_image<P, V>::operator()(const line_graph_psite<P>& p)
{
- mln_precondition(&p.plg() == &this->data_->plg_);
+ mln_precondition(p.plg() == this->data_->plg_);
mln_precondition(p.id() < this->data_->edge_val_.size());
return this->data_->edge_val_[p.id()];
}
Index: mln/core/line_graph_psite.hh
--- mln/core/line_graph_psite.hh (revision 1799)
+++ mln/core/line_graph_psite.hh (working copy)
@@ -176,7 +176,7 @@
bool
line_graph_psite<P>::is_valid_() const
{
- return plg_ && id_ < plg_->gr_.nedges();
+ return plg_ && id_ < plg_->gr_->nedges();
}
template<typename P>
@@ -228,7 +228,7 @@
line_graph_psite<P>::first() const
{
mln_assertion(is_valid_());
- return plg().gr_.node_data(plg().gr_.edge(id_).n1());
+ return plg().gr_->node_data(plg().gr_->edge(id_).n1());
}
template<typename P>
@@ -237,7 +237,7 @@
line_graph_psite<P>::second() const
{
mln_assertion(is_valid_());
- return plg().gr_.node_data(plg().gr_.edge(id_).n2());
+ return plg().gr_->node_data(plg().gr_->edge(id_).n2());
}
Index: mln/core/line_graph_neighborhood_piter.hh
--- mln/core/line_graph_neighborhood_piter.hh (revision 1799)
+++ mln/core/line_graph_neighborhood_piter.hh (working copy)
@@ -258,7 +258,7 @@
// FIXME: We depend too much on the implementation of util::graph
// here. The util::graph should provide the service to abstract
// these manipulations.
- return id_ < p_ref_.plg().gr_.nedges();
+ return id_ < p_ref_.plg().gr_->nedges();
}
template <typename P>
@@ -315,19 +315,20 @@
// Check whether the iterator is among the neighbors of P_REF_.
{
// Paranoid assertion.
- assert (p_ref_.id() < p_ref_.plg().gr_.nedges());
+ assert (p_ref_.id() < p_ref_.plg().gr_->nedges());
/* FIXME: We should have a convenient shortcut for these
repetitive accesses to p_ref_.plg().gr_ (e.g., a method gr()
or g() in this class. */
- const typename p_line_graph<P>::graph& gr = p_ref_.plg().gr_;
+ const util::tracked_ptr<typename p_line_graph<P>::graph>& gr =
+ p_ref_.plg().gr_;
// Check whether the edge this iterator points to is adjacent to
// the one p_ref points to, by comparing their ajacent nodes.
/* FIXME: This is too low-level. Yet another service the graph
// should provide. */
- if (gr.edge(id_).n1() == gr.edge(p_ref_.id()).n1() ||
- gr.edge(id_).n1() == gr.edge(p_ref_.id()).n2() ||
- gr.edge(id_).n2() == gr.edge(p_ref_.id()).n1() ||
- gr.edge(id_).n2() == gr.edge(p_ref_.id()).n2())
+ if (gr->edge(id_).n1() == gr->edge(p_ref_.id()).n1() ||
+ gr->edge(id_).n1() == gr->edge(p_ref_.id()).n2() ||
+ gr->edge(id_).n2() == gr->edge(p_ref_.id()).n1() ||
+ gr->edge(id_).n2() == gr->edge(p_ref_.id()).n2())
return true;
}
@@ -413,7 +414,7 @@
// FIXME: We depend too much on the implementation of util::graph
// here. The util::graph should provide the service to abstract
// these manipulations.
- return id_ < p_ref_.plg().gr_.nedges();
+ return id_ < p_ref_.plg().gr_->nedges();
}
template <typename P>
@@ -429,7 +430,7 @@
void
line_graph_neighborhood_bkd_piter<P>::start()
{
- id_ = p_ref_.plg().gr_.nedges() - 1;
+ id_ = p_ref_.plg().gr_->nedges() - 1;
if (!adjacent_or_equal_to_p_ref_())
next_();
/* FIXME: This is redundant with the end of next_(), but we might
@@ -470,19 +471,20 @@
// Check whether the iterator is among the neighbors of P_REF_.
{
// Paranoid assertion.
- assert (p_ref_.id() < p_ref_.plg().gr_.nedges());
+ assert (p_ref_.id() < p_ref_.plg().gr_->nedges());
/* FIXME: We should have a convenient shortcut for these
repetitive accesses to p_ref_.plg().gr_ (e.g., a method gr()
or g() in this class. */
- const typename p_line_graph<P>::graph& gr = p_ref_.plg().gr_;
+ const util::tracked_ptr<typename p_line_graph<P>::graph>& gr =
+ p_ref_.plg().gr_;
// Check whether the edge this iterator points to is adjacent to
// the one p_ref points to, by comparing their ajacent nodes.
/* FIXME: This is too low-level. Yet another service the graph
// should provide. */
- if (gr.edge(id_).n1() == gr.edge(p_ref_.id()).n1() ||
- gr.edge(id_).n1() == gr.edge(p_ref_.id()).n2() ||
- gr.edge(id_).n2() == gr.edge(p_ref_.id()).n1() ||
- gr.edge(id_).n2() == gr.edge(p_ref_.id()).n2())
+ if (gr->edge(id_).n1() == gr->edge(p_ref_.id()).n1() ||
+ gr->edge(id_).n1() == gr->edge(p_ref_.id()).n2() ||
+ gr->edge(id_).n2() == gr->edge(p_ref_.id()).n1() ||
+ gr->edge(id_).n2() == gr->edge(p_ref_.id()).n2())
return true;
}
Index: mln/core/line_graph_window_piter.hh
--- mln/core/line_graph_window_piter.hh (revision 1799)
+++ mln/core/line_graph_window_piter.hh (working copy)
@@ -252,7 +252,7 @@
// FIXME: We depend too much on the implementation of util::graph
// here. The util::graph should provide the service to abstract
// these manipulations.
- return id_ < p_ref_.plg().gr_.nedges();
+ return id_ < p_ref_.plg().gr_->nedges();
}
template <typename P>
@@ -309,19 +309,20 @@
// Check whether the iterator is among the neighbors of P_REF_.
{
// Paranoid assertion.
- assert (p_ref_.id() < p_ref_.plg().gr_.nedges());
+ assert (p_ref_.id() < p_ref_.plg().gr_->nedges());
/* FIXME: We should have a convenient shortcut for these
repetitive accesses to p_ref_.plg().gr_ (e.g., a method gr()
or g() in this class. */
- const typename p_line_graph<P>::graph& gr = p_ref_.plg().gr_;
+ const util::tracked_ptr<typename p_line_graph<P>::graph>& gr =
+ p_ref_.plg().gr_;
// Check whether the edge this iterator points to is adjacent to
// the one p_ref points to, by comparing their ajacent nodes.
/* FIXME: This is too low-level. Yet another service the graph
// should provide. */
- if (gr.edge(id_).n1() == gr.edge(p_ref_.id()).n1() ||
- gr.edge(id_).n1() == gr.edge(p_ref_.id()).n2() ||
- gr.edge(id_).n2() == gr.edge(p_ref_.id()).n1() ||
- gr.edge(id_).n2() == gr.edge(p_ref_.id()).n2())
+ if (gr->edge(id_).n1() == gr->edge(p_ref_.id()).n1() ||
+ gr->edge(id_).n1() == gr->edge(p_ref_.id()).n2() ||
+ gr->edge(id_).n2() == gr->edge(p_ref_.id()).n1() ||
+ gr->edge(id_).n2() == gr->edge(p_ref_.id()).n2())
return true;
}
@@ -406,7 +407,7 @@
// FIXME: We depend too much on the implementation of util::graph
// here. The util::graph should provide the service to abstract
// these manipulations.
- return id_ < p_ref_.plg().gr_.nedges();
+ return id_ < p_ref_.plg().gr_->nedges();
}
template <typename P>
@@ -422,7 +423,7 @@
void
line_graph_window_bkd_piter<P>::start()
{
- id_ = p_ref_.plg().gr_.nedges() - 1;
+ id_ = p_ref_.plg().gr_->nedges() - 1;
if (!adjacent_or_equal_to_p_ref_())
next_();
/* FIXME: This is redundant with the end of next_(), but we might
@@ -463,19 +464,20 @@
// Check whether the iterator is among the neighbors of P_REF_.
{
// Paranoid assertion.
- assert (p_ref_.id() < p_ref_.plg().gr_.nedges());
+ assert (p_ref_.id() < p_ref_.plg().gr_->nedges());
/* FIXME: We should have a convenient shortcut for these
repetitive accesses to p_ref_.plg().gr_ (e.g., a method gr()
or g() in this class. */
- const typename p_line_graph<P>::graph& gr = p_ref_.plg().gr_;
+ const util::tracked_ptr<typename p_line_graph<P>::graph>& gr =
+ p_ref_.plg().gr_;
// Check whether the edge this iterator points to is adjacent to
// the one p_ref points to, by comparing their ajacent nodes.
/* FIXME: This is too low-level. Yet another service the graph
// should provide. */
- if (gr.edge(id_).n1() == gr.edge(p_ref_.id()).n1() ||
- gr.edge(id_).n1() == gr.edge(p_ref_.id()).n2() ||
- gr.edge(id_).n2() == gr.edge(p_ref_.id()).n1() ||
- gr.edge(id_).n2() == gr.edge(p_ref_.id()).n2())
+ if (gr->edge(id_).n1() == gr->edge(p_ref_.id()).n1() ||
+ gr->edge(id_).n1() == gr->edge(p_ref_.id()).n2() ||
+ gr->edge(id_).n2() == gr->edge(p_ref_.id()).n1() ||
+ gr->edge(id_).n2() == gr->edge(p_ref_.id()).n2())
return true;
}
1
0
URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena
ChangeLog:
2008-03-22 Etienne FOLIO <folio(a)lrde.epita.fr>
Cleanup of the sandbox.
* chamfer_dt.cc: Remove.
* dmap.cc: Remove.
* dt_naive.cc: Remove.
* dt_naive.hh: Remove.
* exercices/heritage_conditionnel.cc: New.
* exercices/heritage_conditionnel.hh: New.
* exercices: New.
* heritage_conditionnel.cc: Remove.
* heritage_conditionnel.hh: Remove.
---
heritage_conditionnel.cc | 7 +++++++
heritage_conditionnel.hh | 46 ++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 53 insertions(+)
Index: trunk/milena/sandbox/folio/chamfer_dt.cc (deleted)
===================================================================
Index: trunk/milena/sandbox/folio/heritage_conditionnel.cc (deleted)
===================================================================
Index: trunk/milena/sandbox/folio/dmap.cc (deleted)
===================================================================
Index: trunk/milena/sandbox/folio/dt_naive.hh (deleted)
===================================================================
Index: trunk/milena/sandbox/folio/heritage_conditionnel.hh (deleted)
===================================================================
Index: trunk/milena/sandbox/folio/dt_naive.cc (deleted)
===================================================================
Index: trunk/milena/sandbox/folio/exercices/heritage_conditionnel.cc
===================================================================
--- trunk/milena/sandbox/folio/exercices/heritage_conditionnel.cc (revision 0)
+++ trunk/milena/sandbox/folio/exercices/heritage_conditionnel.cc (revision 1799)
@@ -0,0 +1,7 @@
+#include "heritage_conditionnel.hh"
+
+int main()
+{
+ new Bottom<1 == 1>();
+ new Bottom<1 == 0>();
+}
Index: trunk/milena/sandbox/folio/exercices/heritage_conditionnel.hh
===================================================================
--- trunk/milena/sandbox/folio/exercices/heritage_conditionnel.hh (revision 0)
+++ trunk/milena/sandbox/folio/exercices/heritage_conditionnel.hh (revision 1799)
@@ -0,0 +1,46 @@
+#ifndef HERITAGE_CONDITIONNEL_HH_
+# define HERITAGE_CONDITIONNEL_HH_
+
+# include <iostream>
+
+class TopLeft
+{
+protected:
+ TopLeft()
+ {
+ std::cout << "top left" << std::endl;
+ }
+};
+
+class TopRight
+{
+protected:
+ TopRight()
+ {
+ std::cout << "top right" << std::endl;
+ }
+};
+
+template<bool C, typename T, typename U>
+struct TraitCond
+{
+ typedef T type;
+};
+
+template<typename T, typename U>
+struct TraitCond<false, T, U>
+{
+ typedef U type;
+};
+
+template<bool B>
+class Bottom: public TraitCond<B, TopLeft, TopRight>::type
+{
+public:
+ Bottom()
+ : TraitCond<B, TopLeft, TopRight>::type()
+ {
+ }
+};
+
+#endif /* !HERITAGE_CONDITIONNEL_HH_ */
1
0
URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena
ChangeLog:
2008-03-22 Etienne FOLIO <folio(a)lrde.epita.fr>
Naive DT rebuilt. Does not compile.
* naive.cc: Uses a given function to calculate the norm.
---
naive.cc | 149 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 149 insertions(+)
Index: trunk/milena/sandbox/folio/naive.cc
===================================================================
--- trunk/milena/sandbox/folio/naive.cc (revision 0)
+++ trunk/milena/sandbox/folio/naive.cc (revision 1798)
@@ -0,0 +1,149 @@
+// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory (LRDE)
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// 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 TODO
+ *
+ * \brief Defines a function that creates a distance map corresponding to a
+ * given image.
+ */
+
+#ifndef MLN_DT_NAIVE_HH
+# define MLN_DT_NAIVE_HH
+
+# include <mln/core/concept/image.hh>
+# include <mln/literal/zero.hh>
+# include <mln/accu/min.hh>
+
+namespace mln
+{
+
+ namespace dt
+ {
+
+ /*! Calculates the distance map corresponding to a given image
+ *
+ * \param[in] input_ The binary reference image.
+ * \param[in] fun_ The function used for distance aclculus.
+ * \return New distance map image.
+ *
+ * \pre \p input_ has to be initialized.
+ *
+ * \fixme Use instead of R the result type of F::operator().
+ */
+ template <typename I, typename F, typename R>
+ mln_ch_value(I, R)
+ naive(const Image<I>& input_, F& fun_);
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ // Facade.
+
+ template <typename I, typename F, typename R>
+ inline
+ mln_ch_value(I, R)
+ naive(const Image<I>& input_, F& fun_)
+ {
+ const I& input = exact(input_);
+ mln_precondition(input.has_data());
+
+ mln_ch_value(I, R) output;
+ initialize(input.domain());
+
+ mln_piter(I) p(input.domain());
+ for_all(p)
+ {
+ if (input(p))
+ output(p) = literal::zero;
+ else
+ {
+ // p is in the background so the distance has to be computed.
+ accu::min_<R> min;
+ min.init();
+
+ mln_piter(I) q(input.domain());
+ for_all(q)
+ if (input(q))
+ {
+ // q is in the object.
+// metal::vec<2, int> vp = p.to_point(), vq = q.to_point();
+// min.take(fun_(vp, vq));
+ min.take(fun_(p, q));
+ }
+ output(p) = min;
+ }
+ }
+
+ return output;
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::dt
+
+} // end of namespace mln
+
+#endif // ! MLN_DT_NAIVE_HH
+
+#include <iostream>
+#include <mln/debug/println.hh>
+#include <mln/core/image2d.hh>
+#include <mln/level/fill.hh>
+#include <mln/norm/l2.hh>
+
+struct l2norm
+{
+ template <typename C, typename D>
+ D
+ operator()(C a, C b)
+ {
+ return mln::norm::l2(a, b);
+ }
+};
+
+int main()
+{
+ using namespace mln;
+
+ {
+ image2d<bool> ima(5,5);
+ bool vals[] = { 1, 1, 1, 0, 0,
+ 0, 0, 1, 0, 0,
+ 0, 0, 1, 0, 0,
+ 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0 };
+
+ level::fill(ima, vals);
+ debug::println(ima);
+
+ l2norm fun;
+ image2d<float> out = dt::naive(ima, fun);
+
+ std::cerr << "Distance:" << std::endl;
+ debug::println(out);
+ }
+}
1
0
URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena
ChangeLog:
2008-03-22 Etienne FOLIO <folio(a)lrde.epita.fr>
Chamfer DT with nearest point calculus.
* chamfer.cc: Returns a pair containing the two maps.
---
chamfer.cc | 189 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 189 insertions(+)
Index: trunk/milena/sandbox/folio/chamfer.cc
===================================================================
--- trunk/milena/sandbox/folio/chamfer.cc (revision 0)
+++ trunk/milena/sandbox/folio/chamfer.cc (revision 1797)
@@ -0,0 +1,189 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef MLN_DT_CHAMFER_HH
+# define MLN_DT_CHAMFER_HH
+
+# include <mln/core/concept/image.hh>
+# include <mln/make/w_window.hh>
+
+namespace mln
+{
+
+ namespace dt
+ {
+
+ /*! Distance tranform by chamfer application.
+ *
+ * \param[in] input_ The input image.
+ * \param[in] chamfer The chamfer window to use for distance calcul.
+ * \return A pair (distance map, nearest point map).
+ *
+ * \pre \p img has to be initialized.
+ */
+ template<typename I, typename T>
+ std::pair<mln_ch_value(I, T), mln_ch_value(I, mln_point(I))>
+ chamfer(const Image<I>& input_,
+ w_window<mln_dpoint(I), T> chamfer);
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ namespace impl
+ {
+
+ /*! Computes a pass of the chamfer DT algorithm.
+ *
+ * \param[in] p Iterator on the input image to use.
+ * \param[in] chamfer The chamfer window to use for distance calcul.
+ * \param[in] input The input image.
+ * \param[out] outputDistance The distance map updated.
+ * \param[out] outputnearest The nearest points map updated.
+ */
+ template<typename Q, typename I, typename T>
+ inline
+ void
+ chamfer_pass(const w_window<mln_dpoint(I), T> chamfer,
+ const I& input,
+ mln_ch_value(I, T)& outputDistance,
+ mln_ch_value(I, mln_point(I))& outputNearest)
+ {
+ typedef w_window<mln_dpoint(I), T> W;
+
+ Q p(input.domain());
+ mln_qiter(W) q(chamfer, p);
+ for_all(p)
+ {
+ std::pair<T, mln_point(I)> min(mln_max(T), p);
+
+ for_all(q)
+ if (input.has(q) && outputDistance(q) != mln_max(T))
+ {
+ T v = outputDistance(q) + q.w();
+
+ if (v < min.first)
+ {
+ min.first = v;
+ min.second = outputNearest(q);
+ }
+ }
+
+ if (min.first < outputDistance(p))
+ {
+ outputDistance(p) = min.first;
+ outputNearest(p) = min.second;
+ }
+ }
+ }
+
+ } // end of namespace mln::dt::impl
+
+
+
+ // Facade.
+
+ template<typename I, typename T>
+ inline
+ std::pair<mln_ch_value(I, T), mln_ch_value(I, mln_point(I))>
+ chamfer(const Image<I>& input_,
+ w_window<mln_dpoint(I), T> chamfer)
+ {
+ typedef w_window<mln_dpoint(I), T> W;
+
+ const I& input = exact(input_);
+ mln_precondition(input.has_data());
+
+ mln_ch_value(I, T) outputDistance;
+ initialize(outputDistance, input);
+
+ mln_ch_value(I, mln_point(I)) outputNearest;
+ initialize(outputNearest, input);
+
+ // Initialization.
+ {
+ mln_fwd_piter(I) p(input.domain());
+ for_all(p)
+ {
+ outputDistance(p) = input(p) ? literal::zero : mln_max(T);
+ outputNearest(p) = p;
+ }
+ }
+
+ // First pass.
+ impl::chamfer_pass<mln_fwd_piter(I)>
+ (chamfer, input, outputDistance, outputNearest);
+
+ chamfer.sym();
+
+ // Second pass.
+ impl::chamfer_pass<mln_bkd_piter(I)>
+ (chamfer, input, outputDistance, outputNearest);
+
+ return std::pair<mln_ch_value(I, T), mln_ch_value(I, mln_point(I))>
+ (outputDistance, outputNearest);
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::dt
+
+} // end of namespace mln
+
+#endif // ! MLN_DT_CHAMFER_HH
+
+#include <iostream>
+#include <mln/debug/println.hh>
+#include <mln/core/image2d.hh>
+#include <mln/make/win_chamfer.hh>
+#include <mln/level/fill.hh>
+
+int main()
+{
+ using namespace mln;
+
+ w_window2d_int chamfer = make::mk_chamfer_3x3_int<3, 4>();
+
+ {
+ image2d<bool> ima(5,5);
+ bool vals[] = { 1, 1, 1, 0, 0,
+ 0, 0, 1, 0, 0,
+ 0, 0, 1, 0, 0,
+ 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0 };
+
+ level::fill(ima, vals);
+ debug::println(ima);
+
+ std::pair<image2d<int>, image2d<mln_point_(image2d<bool>)> >
+ out = dt::chamfer(ima, chamfer);
+
+ std::cerr << "Distance:" << std::endl;
+ debug::println(out.first);
+ std::cerr << "PPP:" << std::endl;
+ debug::println(out.second);
+ }
+}
1
0
URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena
ChangeLog:
2008-03-21 Matthieu Garrigues <garrigues(a)lrde.epita.fr>
Add geom routine for Box.
* mln/geom/max_col.hh:
(mln_coord(B::point) max_col(const Box<B>& b)) New.
* mln/geom/max_row.hh:
(mln_coord(B::point) max_row(const Box<B>& b)) New.
* mln/geom/min_col.hh:
(mln_coord(B::point) min_col(const Box<B>& b)) New.
* mln/geom/min_row.hh:
(mln_coord(B::point) min_row(const Box<B>& b)) New.
* mln/geom/ncols.hh:
(unsigned ncols(const Box<B>& b)) New.
* mln/geom/nrows.hh:
(unsigned nrows(const Box<B>& b)) New.
---
max_col.hh | 12 ++++++++++++
max_row.hh | 13 +++++++++++++
min_col.hh | 13 +++++++++++++
min_row.hh | 16 ++++++++++++++++
ncols.hh | 12 ++++++++++++
nrows.hh | 11 +++++++++++
6 files changed, 77 insertions(+)
Index: trunk/milena/mln/geom/max_col.hh
===================================================================
--- trunk/milena/mln/geom/max_col.hh (revision 1795)
+++ trunk/milena/mln/geom/max_col.hh (revision 1796)
@@ -46,6 +46,9 @@
template <typename I>
mln_coord(I) max_col(const Image<I>& ima);
+ /// Give the maximum col of an box 2d or 3d.
+ template <typename B>
+ mln_coord(B::point) max_col(const Box<B>& b);
# ifndef MLN_INCLUDE_ONLY
@@ -57,6 +60,15 @@
return exact(ima).bbox().pmax().col();
}
+
+ template <typename B>
+ inline
+ mln_coord(B::point) max_col(const Box<B>& b)
+ {
+ metal::not_<metal::equal<metal::int_<B::dim>, metal::int_<1> > >::check();
+ return exact(b).pmax().col();
+ }
+
# endif // ! MLN_INCLUDE_ONLY
} // end of namespace mln::geom
Index: trunk/milena/mln/geom/nrows.hh
===================================================================
--- trunk/milena/mln/geom/nrows.hh (revision 1795)
+++ trunk/milena/mln/geom/nrows.hh (revision 1796)
@@ -47,6 +47,10 @@
template <typename I>
unsigned nrows(const Image<I>& ima);
+ /// Give the number of rows of a box 2d or 3d.
+ template <typename B>
+ unsigned nrows(const Box<B>& b);
+
# ifndef MLN_INCLUDE_ONLY
@@ -58,6 +62,13 @@
return geom::max_row(ima) - geom::min_row(ima) + 1;
}
+ template <typename B>
+ unsigned nrows(const Box<B>& b)
+ {
+ metal::not_<metal::equal<metal::int_<B::dim>, metal::int_<1> > >::check();
+ return geom::max_row(b) - geom::min_row(b) + 1;
+ }
+
# endif // ! MLN_INCLUDE_ONLY
} // end of namespace mln::geom
Index: trunk/milena/mln/geom/min_row.hh
===================================================================
--- trunk/milena/mln/geom/min_row.hh (revision 1795)
+++ trunk/milena/mln/geom/min_row.hh (revision 1796)
@@ -35,6 +35,9 @@
# include <mln/core/concept/image.hh>
+# include <mln/metal/bexpr.hh>
+# include <mln/metal/int.hh>
+# include <mln/metal/equal.hh>
namespace mln
{
@@ -46,6 +49,10 @@
template <typename I>
mln_coord(I) min_row(const Image<I>& ima);
+ /// Give the minimum row of an box 2d or 3d.
+ template <typename B>
+ mln_coord(B::point) min_row(const Box<B>& b);
+
# ifndef MLN_INCLUDE_ONLY
@@ -57,6 +64,15 @@
return exact(ima).bbox().pmin().row();
}
+
+ template <typename B>
+ inline
+ mln_coord(B::point) min_row(const Box<B>& b)
+ {
+ metal::not_<metal::equal<metal::int_<B::dim>, metal::int_<1> > >::check();
+ return exact(b).pmin().row();
+ }
+
# endif // ! MLN_INCLUDE_ONLY
} // end of namespace mln::geom
Index: trunk/milena/mln/geom/max_row.hh
===================================================================
--- trunk/milena/mln/geom/max_row.hh (revision 1795)
+++ trunk/milena/mln/geom/max_row.hh (revision 1796)
@@ -47,6 +47,10 @@
mln_coord(I) max_row(const Image<I>& ima);
+ /// Give the maximum row of an box 2d or 3d.
+ template <typename B>
+ mln_coord(B::point) max_row(const Box<B>& b);
+
# ifndef MLN_INCLUDE_ONLY
template <typename I>
@@ -57,6 +61,15 @@
return exact(ima).bbox().pmax().row();
}
+
+ template <typename B>
+ inline
+ mln_coord(B::point) max_row(const Box<B>& b)
+ {
+ metal::not_<metal::equal<metal::int_<B::dim>, metal::int_<1> > >::check();
+ return exact(b).pmax().row();
+ }
+
# endif // ! MLN_INCLUDE_ONLY
} // end of namespace mln::geom
Index: trunk/milena/mln/geom/ncols.hh
===================================================================
--- trunk/milena/mln/geom/ncols.hh (revision 1795)
+++ trunk/milena/mln/geom/ncols.hh (revision 1796)
@@ -47,6 +47,10 @@
template <typename I>
unsigned ncols(const Image<I>& ima);
+ /// Give the number of cols of a box 2d or 3d.
+ template <typename B>
+ unsigned ncols(const Box<B>& b);
+
# ifndef MLN_INCLUDE_ONLY
@@ -58,6 +62,14 @@
return geom::max_col(ima) - geom::min_col(ima) + 1;
}
+
+ template <typename B>
+ unsigned ncols(const Box<B>& b)
+ {
+ metal::not_<metal::equal<metal::int_<B::dim>, metal::int_<1> > >::check();
+ return geom::max_col(b) - geom::min_col(b) + 1;
+ }
+
# endif // ! MLN_INCLUDE_ONLY
} // end of namespace mln::geom
Index: trunk/milena/mln/geom/min_col.hh
===================================================================
--- trunk/milena/mln/geom/min_col.hh (revision 1795)
+++ trunk/milena/mln/geom/min_col.hh (revision 1796)
@@ -46,6 +46,10 @@
template <typename I>
mln_coord(I) min_col(const Image<I>& ima);
+ /// Give the minimum column of an box 2d or 3d.
+ template <typename B>
+ mln_coord(B::point) min_col(const Box<B>& b);
+
# ifndef MLN_INCLUDE_ONLY
@@ -57,6 +61,15 @@
return exact(ima).bbox().pmin().col();
}
+
+ template <typename B>
+ inline
+ mln_coord(B::point) min_col(const Box<B>& b)
+ {
+ metal::not_<metal::equal<metal::int_<B::dim>, metal::int_<1> > >::check();
+ return exact(b).pmin().col();
+ }
+
# endif // ! MLN_INCLUDE_ONLY
} // end of namespace mln::geom
1
0
URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena
ChangeLog:
2008-03-21 Matthieu Garrigues <garrigues(a)lrde.epita.fr>
Debug tiled_image2d.
* sandbox/garrigues/tiled_image2d/block.hh: Remove the union, to use a
block with a value type of milena.
* sandbox/garrigues/tiled_image2d/layout/image2d/lrtb.hh: in a
milena's point2d, we have p[0] = row index, p[1] = col index, update
to respect this.
* sandbox/garrigues/tiled_image2d/layout/page2d/lrtb.hh: likewise,
(unsigned image2d_lrtb::size(unsigned nrows, unsigned ncols)) New.
* sandbox/garrigues/tiled_image2d/tiled_image2d.cc: Test the type with
a big image.
* sandbox/garrigues/tiled_image2d/tiled_image2d.hh: Allocate enough
space for the image. Fixme : some debug will be removed later.
---
block.hh | 13 +++++++++----
layout/image2d/lrtb.hh | 15 ++++++++++-----
layout/page2d/lrtb.hh | 2 +-
tiled_image2d.cc | 13 +++++++++++--
tiled_image2d.hh | 33 +++++++++++++++++++++++----------
5 files changed, 54 insertions(+), 22 deletions(-)
Index: trunk/milena/sandbox/garrigues/tiled_image2d/tiled_image2d.hh
===================================================================
--- trunk/milena/sandbox/garrigues/tiled_image2d/tiled_image2d.hh (revision 1794)
+++ trunk/milena/sandbox/garrigues/tiled_image2d/tiled_image2d.hh (revision 1795)
@@ -38,11 +38,14 @@
# include <mln/core/box2d.hh>
# include <mln/core/inplace.hh>
# include <mln/core/init.hh>
+# include <mln/core/line_piter.hh>
+
+# include <mln/geom/size2d.hh>
+
# include <mln/border/thickness.hh>
# include <mln/value/set.hh>
# include <mln/fun/i2v/all_to.hh>
-# include <mln/core/line_piter.hh>
# include <fcntl.h>
# include "support/lru.hh"
@@ -52,7 +55,8 @@
# include "page.hh"
// FIXME : give the side's side of the square of the block.
-# define SIDE 128
+# define BLOCK_SIDE 128
+# define BLOCK_SIZE (BLOCK_SIDE * BLOCK_SIDE)
namespace mln
{
@@ -68,10 +72,10 @@
template <typename T>
struct data_< tiled_image2d<T> >
{
- typedef block<T, SIDE * SIDE> block;
+ typedef block<T, BLOCK_SIZE> block;
typedef mmap_backend<block> backend;
typedef lru_support<backend> support;
- typedef layout2d<SIDE, SIDE> layout;
+ typedef layout2d<BLOCK_SIDE, BLOCK_SIDE> layout;
data_(const box2d& b);
~data_();
@@ -149,12 +153,12 @@
typedef mln::value::set<T> vset;
/// Block type.
- typedef block<T, SIDE * SIDE> block;
+ typedef block<T, BLOCK_SIZE> block;
/// Support type.
typedef lru_support<mmap_backend<block> > support;
/// Layout type
- typedef layout2d<SIDE, SIDE> layout;
+ typedef layout2d<BLOCK_SIDE, BLOCK_SIDE> layout;
/// Page type
typedef page<T, layout> page;
@@ -238,11 +242,20 @@
data_< tiled_image2d<T> >::data_(const box2d& b)
: b_ (b),
// FIXME : hard coded path.
- support_(*new support(*new backend( open("/tmp/milena_tiled.image", O_RDWR | O_CREAT | O_TRUNC, 0664), b.npoints()) ))
- {
- std::cout << b.npoints() * sizeof(T) << std::endl;
+ support_(*new support(
+ *new backend( open("/tmp/milena_tiled.image", O_RDWR | O_CREAT | O_TRUNC, 0664),
+ layout::image_layout::size(geom::nrows(b), geom::ncols(b))),
+ 1500 // Fixme : size of lru cache.
+ )
+ )
+ {
+ std::cout << layout::image_layout::size(geom::nrows(b), geom::ncols(b)) << " block dans l'image." << std::endl;
+ std::cout << layout::image_layout::size(geom::nrows(b), geom::ncols(b)) * BLOCK_SIZE * sizeof(T) << " o au total." << std::endl;
+ std::cout << layout::image_layout::size(geom::nrows(b), geom::ncols(b)) * BLOCK_SIZE * sizeof(T) / 1024. << " Ko au total." << std::endl;
+ std::cout << layout::image_layout::size(geom::nrows(b), geom::ncols(b)) * BLOCK_SIZE * sizeof(T) / (1024 * 1024.) << " Mo au total." << std::endl;
+
char a = 0;
- lseek(support_.backend_.fd_, b.npoints() * sizeof(T) - 1, SEEK_SET);
+ lseek(support_.backend_.fd_, layout::image_layout::size(geom::nrows(b), geom::ncols(b)) * BLOCK_SIZE * sizeof(T), SEEK_SET);
write(support_.backend_.fd_, &a, 1);
}
Index: trunk/milena/sandbox/garrigues/tiled_image2d/block.hh
===================================================================
--- trunk/milena/sandbox/garrigues/tiled_image2d/block.hh (revision 1794)
+++ trunk/milena/sandbox/garrigues/tiled_image2d/block.hh (revision 1795)
@@ -37,20 +37,25 @@
struct block : public Object< block<T, size> > {
typedef T value_type;
enum { nitems = size, nbytes = size * sizeof(T) };
- union {
- char bytes[nbytes];
- T array[nitems];
- };
+
+ char bytes[nitems];
+
+// union {
+// char bytes[nbytes];
+// T array[nitems];
+// };
T& operator[](unsigned p)
{
assert(p < nitems);
+ T* array = (T*)(void*) bytes;
return array[p];
}
const T& operator[](unsigned p) const
{
assert(p < nbytes);
+ T* array = (T*)(void*) bytes;
return array[p];
}
};
Index: trunk/milena/sandbox/garrigues/tiled_image2d/tiled_image2d.cc
===================================================================
--- trunk/milena/sandbox/garrigues/tiled_image2d/tiled_image2d.cc (revision 1794)
+++ trunk/milena/sandbox/garrigues/tiled_image2d/tiled_image2d.cc (revision 1795)
@@ -32,14 +32,23 @@
#include "tiled_image2d.hh"
+#include <mln/core/cast_image.hh>
+
#include <mln/level/fill.hh>
+#include <mln/value/int_u8.hh>
#include <mln/debug/println.hh>
+#include <mln/debug/iota.hh>
+#include <mln/io/pgm/save.hh>
int main()
{
using namespace mln;
- tiled_image2d<int> ima(10700, 10700);
+ std::cout << "allocate the image." << std::endl;
+ tiled_image2d<value::int_u8> ima(1024 * 1024, 1024 * 1.5);
+ std::cout << "fill the image." << std::endl;
+ debug::iota(ima);
- level::fill(ima, 6);
+ std::cout << "save the image." << std::endl;
+ io::pgm::save(ima, "test.pgm");
}
Index: trunk/milena/sandbox/garrigues/tiled_image2d/layout/page2d/lrtb.hh
===================================================================
--- trunk/milena/sandbox/garrigues/tiled_image2d/layout/page2d/lrtb.hh (revision 1794)
+++ trunk/milena/sandbox/garrigues/tiled_image2d/layout/page2d/lrtb.hh (revision 1795)
@@ -41,7 +41,7 @@
static unsigned pixel_at(const point2d& p)
{
- return p[1] * width + p[0];
+ return p[0] * width + p[1];
}
};
Index: trunk/milena/sandbox/garrigues/tiled_image2d/layout/image2d/lrtb.hh
===================================================================
--- trunk/milena/sandbox/garrigues/tiled_image2d/layout/image2d/lrtb.hh (revision 1794)
+++ trunk/milena/sandbox/garrigues/tiled_image2d/layout/image2d/lrtb.hh (revision 1795)
@@ -36,30 +36,35 @@
namespace layout {
template<unsigned W, unsigned H>
- struct image2d_lrtb : public Object<image2d_lrtb<W, H> > {
+ struct image2d_lrtb {
enum { dim = 2, page_width = W, page_height = H };
template<typename Image>
static unsigned size(const Image& im) {
const typename Image::domain_type& d = im.domain();
- return (d.len(0) / page_width ) * (d.len(1) / page_height);
+ return (1 + d.len(0) / page_width ) * (1 + d.len(1) / page_height);
+ }
+
+
+ static unsigned size(unsigned nrows, unsigned ncols) {
+ return (1 + ncols / page_width ) * (1 + nrows / page_height);
}
template<typename Image>
static unsigned page_at(const Image& im, const point2d& p)
{
- return (p[1] / page_height) * (im.domain().len(0) / page_width) + p[0] / page_width;
+ unsigned n = (p[0] / page_height) * (1 + im.domain().len(1) / page_width) + (p[1] / page_width);
+ return n;
};
static point2d changeref(const point2d& p)
{
- return point2d(p[0] % page_width, p[1] % page_height);
+ return point2d(p[0] % page_height, p[1] % page_width);
}
};
}
-
} // end of namespace mln
#endif
1
0
URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena
ChangeLog:
2008-03-21 Michel Pellegrin <pellegrin(a)lrde.epita.fr>
Fix some typos, add existant tests.
* sandbox/pellegrin/set/Makefile: Remove.
* sandbox/pellegrin/set/core/concept/point_set.hh: Modified.
* sandbox/pellegrin/set/core/internal/multi_set.hh,
* sandbox/pellegrin/set/core/internal/uni_set.hh: New.
* sandbox/pellegrin/set/core/line2d.hh,
* sandbox/pellegrin/set/core/p_array.hh,
* sandbox/pellegrin/set/core/p_bgraph.hh,
* sandbox/pellegrin/set/core/p_graph.hh,
* sandbox/pellegrin/set/core/p_line_graph.hh,
* sandbox/pellegrin/set/core/p_priority_queue.hh,
* sandbox/pellegrin/set/core/p_priority_queue_fast.hh,
* sandbox/pellegrin/set/core/p_priority_queue_fast_with_array.hh,
* sandbox/pellegrin/set/core/p_queue.hh,
* sandbox/pellegrin/set/core/p_queue_fast.hh,
* sandbox/pellegrin/set/core/p_run.hh,
* sandbox/pellegrin/set/core/p_runs.hh,
* sandbox/pellegrin/set/core/p_set.hh,
* sandbox/pellegrin/set/core/pset_if.hh: Modify an #include and add a
semi-colon after the trait struct.
* sandbox/pellegrin/set/multi_set.hh: Remove.
* sandbox/pellegrin/set/test: New folder containing tests.
* sandbox/pellegrin/set/test/Makefile,
* sandbox/pellegrin/set/test/test.sh,
* sandbox/pellegrin/set/test/detest.sh: New, for the compilation.
* sandbox/pellegrin/set/test/p_bgraph.cc,
* sandbox/pellegrin/set/test/p_priority_queue.cc,
* sandbox/pellegrin/set/test/p_priority_queue_fast.cc,
* sandbox/pellegrin/set/test/p_priority_queue_fast_with_array.cc,
* sandbox/pellegrin/set/test/p_queue.cc,
* sandbox/pellegrin/set/test/p_queue_fast.cc,
* sandbox/pellegrin/set/test/p_runs.cc,
* sandbox/pellegrin/set/test/p_set.cc,
* sandbox/pellegrin/set/test/pset_if.cc: New tests.
* sandbox/pellegrin/set/test_set.cc: Remove.
* sandbox/pellegrin/set/trait/point_set.hh: Minor fix.
* sandbox/pellegrin/set/uni_set.hh: Remove.
---
core/concept/point_set.hh | 8 -
core/internal/multi_set.hh | 176 +++++++++++++++++++++++++++++++
core/internal/uni_set.hh | 176 +++++++++++++++++++++++++++++++
core/line2d.hh | 4
core/p_array.hh | 4
core/p_bgraph.hh | 4
core/p_graph.hh | 4
core/p_line_graph.hh | 4
core/p_priority_queue.hh | 10 -
core/p_priority_queue_fast.hh | 4
core/p_priority_queue_fast_with_array.hh | 8 -
core/p_queue.hh | 4
core/p_queue_fast.hh | 4
core/p_run.hh | 4
core/p_runs.hh | 4
core/p_set.hh | 4
core/pset_if.hh | 4
test/Makefile | 16 ++
test/detest.sh | 17 ++
test/p_bgraph.cc | 85 ++++++++++++++
test/p_priority_queue.cc | 98 +++++++++++++++++
test/p_priority_queue_fast.cc | 98 +++++++++++++++++
test/p_priority_queue_fast_with_array.cc | 105 ++++++++++++++++++
test/p_queue.cc | 57 ++++++++++
test/p_queue_fast.cc | 57 ++++++++++
test/p_runs.cc | 82 ++++++++++++++
test/p_set.cc | 57 ++++++++++
test/pset_if.cc | 53 +++++++++
test/test.sh | 18 +++
trait/point_set.hh | 2
30 files changed, 1130 insertions(+), 41 deletions(-)
Index: trunk/milena/sandbox/pellegrin/set/multi_set.hh (deleted)
===================================================================
Index: trunk/milena/sandbox/pellegrin/set/uni_set.hh (deleted)
===================================================================
Index: trunk/milena/sandbox/pellegrin/set/Makefile (deleted)
===================================================================
Index: trunk/milena/sandbox/pellegrin/set/test_set.cc (deleted)
===================================================================
Index: trunk/milena/sandbox/pellegrin/set/test/detest.sh
===================================================================
--- trunk/milena/sandbox/pellegrin/set/test/detest.sh (revision 0)
+++ trunk/milena/sandbox/pellegrin/set/test/detest.sh (revision 1794)
@@ -0,0 +1,17 @@
+#! /bin/sh
+
+lol="line2d.hh p_bgraph.hh p_line_graph.hh p_priority_queue_fast_with_array.hh
+p_queue_fast.hh p_run.hh p_set.hh p_array.hh p_graph.hh p_priority_queue_fast.hh
+p_priority_queue.hh p_queue.hh p_runs.hh pset_if.hh"
+mln_path="../../../../mln"
+
+if ! [ -f $mln_path/core/stamp ]; then
+ exit 1;
+fi
+
+for i in $lol;
+do
+ mv -v $mln_path/core/$i.bak $mln_path/core/$i;
+done
+
+rm -v $mln_path/core/stamp
Property changes on: trunk/milena/sandbox/pellegrin/set/test/detest.sh
___________________________________________________________________
Name: svn:executable
+ *
Index: trunk/milena/sandbox/pellegrin/set/test/p_queue_fast.cc
===================================================================
--- trunk/milena/sandbox/pellegrin/set/test/p_queue_fast.cc (revision 0)
+++ trunk/milena/sandbox/pellegrin/set/test/p_queue_fast.cc (revision 1794)
@@ -0,0 +1,57 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+/*! \file tests/core/p_queue_fast.cc
+ *
+ * \brief Tests on mln::p_queue_fast.
+ */
+
+#include <mln/core/point2d.hh>
+#include <mln/core/p_queue_fast.hh>
+
+
+
+int main()
+{
+ using namespace mln;
+
+ p_queue_fast<point2d> q;
+ q
+ .push(make::point2d(6, 9))
+ .push(make::point2d(5, 1))
+ .push(make::point2d(4, 2));
+ mln_assertion(q.npoints() == 3);
+
+ std::cout << q.bbox() << std::endl;
+ std::cout << q << std::endl;
+
+ q.pop();
+ mln_assertion(q.npoints() == 2);
+ point2d p = q.front();
+ mln_assertion(q.npoints() == 2);
+ mln_assertion(p == make::point2d(5, 1));
+}
Index: trunk/milena/sandbox/pellegrin/set/test/p_priority_queue_fast.cc
===================================================================
--- trunk/milena/sandbox/pellegrin/set/test/p_priority_queue_fast.cc (revision 0)
+++ trunk/milena/sandbox/pellegrin/set/test/p_priority_queue_fast.cc (revision 1794)
@@ -0,0 +1,98 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+/*! \file tests/core/p_priority_queue_fast.cc
+ *
+ * \brief Tests on mln::p_priority_queue_fast.
+ */
+
+#include <mln/core/point2d.hh>
+#include <mln/core/p_priority_queue_fast.hh>
+
+int main ()
+{
+ using namespace mln;
+
+ mln::p_priority_queue_fast<point2d, unsigned> q;
+ point2d p1 (6, 9);
+ point2d p2 (5, 1);
+ point2d p3 (4, 2);
+
+ mln_assertion (q.is_empty ());
+
+ mln_assertion (q.npoints () == 0);
+
+ q.push_force (p3);
+ q.push_force (p1, 3);
+ q.push_force (p2, 5);
+
+ std::cout << q.bbox () << std::endl;
+ std::cout << q << std::endl;
+
+ mln_assertion (!q.is_empty ());
+
+ mln_assertion (q.has (p1));
+ mln_assertion (q.has (p2));
+ mln_assertion (q.has (p3));
+
+ mln_assertion (q.npoints () == 3);
+ mln_assertion (q.front () == p2);
+ q.pop ();
+
+ mln_assertion (q.has (p1));
+ mln_assertion (!q.has (p2));
+ mln_assertion (q.has (p3));
+
+ mln_assertion (q.npoints () == 2);
+ mln_assertion (q.front () == p1);
+ q.pop ();
+
+ mln_assertion (!q.has (p1));
+ mln_assertion (!q.has (p2));
+ mln_assertion (q.has (p3));
+
+ mln_assertion (q.npoints () == 1);
+ mln_assertion (q.front () == p3);
+ q.pop ();
+
+ mln_assertion (!q.has (p1));
+ mln_assertion (!q.has (p2));
+ mln_assertion (!q.has (p3));
+ mln_assertion (q.npoints () == 0);
+
+ mln_assertion (q.is_empty ());
+
+ q.push_force (p3);
+ q.push_force (p2, 5);
+ q.push_force (p1, 3);
+
+ mln_assertion (q[2] == p3);
+ mln_assertion (q[1] == p1);
+ mln_assertion (q[0] == p2);
+ q.clear ();
+ mln_assertion (q.is_empty ());
+}
Index: trunk/milena/sandbox/pellegrin/set/test/p_bgraph.cc
===================================================================
--- trunk/milena/sandbox/pellegrin/set/test/p_bgraph.cc (revision 0)
+++ trunk/milena/sandbox/pellegrin/set/test/p_bgraph.cc (revision 1794)
@@ -0,0 +1,85 @@
+// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory (LRDE)
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// 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/core/p_bgraph.cc
+/// \brief Tests on mln::p_bgraph (the psite based on boost-graph).
+
+#include "../core/p_bgraph.hh"
+#include <mln/core/point2d.hh>
+#include <mln/util/internal/boost_graph.hh>
+#include <boost/typeof/std/utility.hpp>
+
+struct empty {};
+
+int main()
+{
+ /*--------------.
+ | boost_graph. |
+ `--------------*/
+
+ using namespace mln;
+ typedef util::internal::boost_graph<point2d, util::empty> Graph;
+
+ // Make convenient labels for the vertices
+ const int num_vertices = 5;
+
+ // writing out the edges in the graph
+ typedef std::pair<int, int> Edge;
+ Edge edge_array[] = {
+ Edge(0, 1), Edge(0, 3), Edge(2, 0), Edge(3, 2),
+ Edge(2, 4), Edge(1, 3), Edge(3, 4)
+ };
+
+ const int num_edges = sizeof(edge_array)/sizeof(edge_array[0]);
+ // declare a graph object
+ Graph g(num_vertices);
+
+ // add the edges to the graph object
+ for (int i = 0; i < num_edges; ++i)
+ boost::add_edge(edge_array[i].first, edge_array[i].second, g);
+
+ g[0] = make::point2d(0, 0);
+ g[1] = make::point2d(0, 1);
+ g[2] = make::point2d(1, 0);
+ g[3] = make::point2d(1, 1);
+ g[4] = make::point2d(0, 2);
+
+ /*-----------.
+ | p_bgraph. |
+ `-----------*/
+
+ /// Creation
+ p_bgraph<point2d> pset(&g);
+
+ /// Iterator
+ p_bgraph_piter_<point2d> p(pset);
+
+ for (p.start(); p.is_valid(); p.next())
+ std::cout << p << std::endl;
+
+ return 0;
+}
Index: trunk/milena/sandbox/pellegrin/set/test/p_queue.cc
===================================================================
--- trunk/milena/sandbox/pellegrin/set/test/p_queue.cc (revision 0)
+++ trunk/milena/sandbox/pellegrin/set/test/p_queue.cc (revision 1794)
@@ -0,0 +1,57 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+/*! \file tests/core/p_queue.cc
+ *
+ * \brief Tests on mln::p_queue.
+ */
+
+#include <mln/core/point2d.hh>
+#include <mln/core/p_queue.hh>
+
+
+
+int main()
+{
+ using namespace mln;
+
+ p_queue<point2d> q;
+ q
+ .push(make::point2d(6, 9))
+ .push(make::point2d(5, 1))
+ .push(make::point2d(4, 2));
+ mln_assertion(q.npoints() == 3);
+
+ std::cout << q.bbox() << std::endl;
+ std::cout << q << std::endl;
+
+ q.pop();
+ mln_assertion(q.npoints() == 2);
+ point2d p = q.front();
+ mln_assertion(q.npoints() == 2);
+ mln_assertion(p == make::point2d(5, 1));
+}
Index: trunk/milena/sandbox/pellegrin/set/test/p_priority_queue.cc
===================================================================
--- trunk/milena/sandbox/pellegrin/set/test/p_priority_queue.cc (revision 0)
+++ trunk/milena/sandbox/pellegrin/set/test/p_priority_queue.cc (revision 1794)
@@ -0,0 +1,98 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+/*! \file tests/core/p_priority_queue.cc
+ *
+ * \brief Tests on mln::p_priority_queue.
+ */
+
+#include <mln/core/point2d.hh>
+#include <mln/core/p_priority_queue.hh>
+
+int main ()
+{
+ using namespace mln;
+
+ p_priority_queue<point2d, unsigned> q;
+ point2d p1 (6, 9);
+ point2d p2 (5, 1);
+ point2d p3 (4, 2);
+
+ mln_assertion (q.is_empty ());
+
+ mln_assertion (q.npoints () == 0);
+
+ q.push_force (p3);
+ q.push_force (p1, 3);
+ q.push_force (p2, 5);
+
+ std::cout << q.bbox () << std::endl;
+ std::cout << q << std::endl;
+
+ mln_assertion (!q.is_empty ());
+
+ mln_assertion (q.has (p1));
+ mln_assertion (q.has (p2));
+ mln_assertion (q.has (p3));
+
+ mln_assertion (q.npoints () == 3);
+ mln_assertion (q.front () == p2);
+ q.pop ();
+
+ mln_assertion (q.has (p1));
+ mln_assertion (!q.has (p2));
+ mln_assertion (q.has (p3));
+
+ mln_assertion (q.npoints () == 2);
+ mln_assertion (q.front () == p1);
+ q.pop ();
+
+ mln_assertion (!q.has (p1));
+ mln_assertion (!q.has (p2));
+ mln_assertion (q.has (p3));
+
+ mln_assertion (q.npoints () == 1);
+ mln_assertion (q.front () == p3);
+ q.pop ();
+
+ mln_assertion (!q.has (p1));
+ mln_assertion (!q.has (p2));
+ mln_assertion (!q.has (p3));
+ mln_assertion (q.npoints () == 0);
+
+ mln_assertion (q.is_empty ());
+
+ q.push_force (p3);
+ q.push_force (p2, 5);
+ q.push_force (p1, 3);
+
+ mln_assertion (q[2] == p3);
+ mln_assertion (q[1] == p1);
+ mln_assertion (q[0] == p2);
+ q.clear ();
+ mln_assertion (q.is_empty ());
+}
Index: trunk/milena/sandbox/pellegrin/set/test/test.sh
===================================================================
--- trunk/milena/sandbox/pellegrin/set/test/test.sh (revision 0)
+++ trunk/milena/sandbox/pellegrin/set/test/test.sh (revision 1794)
@@ -0,0 +1,18 @@
+#! /bin/sh
+
+lol="line2d.hh p_bgraph.hh p_line_graph.hh p_priority_queue_fast_with_array.hh
+p_queue_fast.hh p_run.hh p_set.hh p_array.hh p_graph.hh p_priority_queue_fast.hh
+p_priority_queue.hh p_queue.hh p_runs.hh pset_if.hh"
+mln_path="../../../../mln"
+
+if [ -f $mln_path/core/stamp ]; then
+ exit 1;
+fi
+
+for i in $lol;
+do
+ mv -v $mln_path/core/$i $mln_path/core/$i.bak;
+ cp -v ../core/$i $mln_path/core/;
+done
+
+touch $mln_path/core/stamp
Property changes on: trunk/milena/sandbox/pellegrin/set/test/test.sh
___________________________________________________________________
Name: svn:executable
+ *
Index: trunk/milena/sandbox/pellegrin/set/test/p_runs.cc
===================================================================
--- trunk/milena/sandbox/pellegrin/set/test/p_runs.cc (revision 0)
+++ trunk/milena/sandbox/pellegrin/set/test/p_runs.cc (revision 1794)
@@ -0,0 +1,82 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+/*! \file tests/core/p_runs.cc
+ *
+ * \brief Test on mln::p_runs_ and related tools.
+ */
+
+#include <mln/core/image2d.hh>
+#include <mln/core/p_runs.hh>
+
+
+template <typename Pset>
+void parc(const Pset& pset)
+{
+ mln_fwd_piter(Pset) it_(pset);
+ for_all(it_)
+ std::cout << it_ << std::endl;
+
+ mln_bkd_piter(Pset) rit_(pset);
+ for_all(rit_)
+ std::cout << rit_ << std::endl;
+}
+
+
+int main()
+{
+ using namespace mln;
+
+ point2d p, q, r;
+ p = make::point2d(2, 4);
+ q = make::point2d(18, 42);
+ r = make::point2d(50, 76);
+
+ // Pset test
+ p_runs_<point2d> ps;
+ p_runs_<point2d> ps2;
+
+ ps.insert(p_run<point2d>(p, 7));
+ mln_assertion(ps.npoints() == 7);
+
+ ps.insert(p_run<point2d>(q, 5));
+ mln_assertion(ps.npoints() == 12);
+
+ ps.insert(p_run<point2d>(r, 2));
+
+ ps.insert(p_run<point2d>(make::point2d(17,40), 6));
+
+ // Psite declaration
+ runs_psite<point2d> site(ps, 5, 0);
+ runs_psite<point2d> site2(ps, 5, 1);
+
+ mln_assertion(ps.has(site));
+ mln_assertion(!ps2.has(site2));
+
+
+ parc(ps);
+}
Index: trunk/milena/sandbox/pellegrin/set/test/pset_if.cc
===================================================================
--- trunk/milena/sandbox/pellegrin/set/test/pset_if.cc (revision 0)
+++ trunk/milena/sandbox/pellegrin/set/test/pset_if.cc (revision 1794)
@@ -0,0 +1,53 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+/*! \file tests/core_pset_if.cc
+ *
+ * \brief Tests on mln::pset_if.
+ */
+
+#include <mln/core/image2d.hh>
+#include <mln/core/p_set.hh>
+#include <mln/core/pset_if.hh>
+#include <mln/fun/p2b/chess.hh>
+#include <mln/convert/to_image.hh>
+#include <mln/convert/to_p_set.hh>
+
+
+int main()
+{
+ using namespace mln;
+
+ box2d box_8x8 = make::box2d(8, 8);
+ mln_assertion((box_8x8 | fun::p2b::chess).npoints() == 32);
+
+ {
+ p_set<point2d> s = convert::to_p_set(box_8x8 | fun::p2b::chess);
+ std::cout << (box_8x8 | fun::p2b::chess) << std::endl;
+ std::cout << s << std::endl;
+ }
+}
Index: trunk/milena/sandbox/pellegrin/set/test/Makefile
===================================================================
--- trunk/milena/sandbox/pellegrin/set/test/Makefile (revision 0)
+++ trunk/milena/sandbox/pellegrin/set/test/Makefile (revision 1794)
@@ -0,0 +1,16 @@
+all:
+ ./test.sh
+ g++-4.2 -ansi -pedantic -W -Wall -Werror -Wextra -I../../../.. -I../ p_bgraph.cc -o bgraph
+ g++-4.2 -ansi -pedantic -W -Wall -Werror -Wextra -I../../../.. -I../ p_priority_queue.cc -o priority_queue
+ g++-4.2 -ansi -pedantic -W -Wall -Werror -Wextra -I../../../.. -I../ p_priority_queue_fast.cc -o priority_queue_fast
+ g++-4.2 -ansi -pedantic -W -Wall -Werror -Wextra -I../../../.. -I../ p_priority_queue_fast_with_array.cc -o priority_queue_fast_with_array
+ g++-4.2 -ansi -pedantic -W -Wall -Werror -Wextra -I../../../.. -I../ p_queue.cc -o queue
+ g++-4.2 -ansi -pedantic -W -Wall -Werror -Wextra -I../../../.. -I../ p_queue_fast.cc -o queue_fast
+ g++-4.2 -ansi -pedantic -W -Wall -Werror -Wextra -I../../../.. -I../ p_runs.cc -o runs
+ g++-4.2 -ansi -pedantic -W -Wall -Werror -Wextra -I../../../.. -I../ p_set.cc -o set
+ g++-4.2 -ansi -pedantic -W -Wall -Werror -Wextra -I../../../.. -I../ pset_if.cc -o pset_if
+ ./detest.sh
+
+clean:
+ rm -vf bgraph priority_queue priority_queue_fast priority_queue_fast_with_array \
+ queue queue_fast runs set pset_if
Index: trunk/milena/sandbox/pellegrin/set/test/p_set.cc
===================================================================
--- trunk/milena/sandbox/pellegrin/set/test/p_set.cc (revision 0)
+++ trunk/milena/sandbox/pellegrin/set/test/p_set.cc (revision 1794)
@@ -0,0 +1,57 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+/*! \file tests/core_p_set.cc
+ *
+ * \brief Tests on mln::p_set.
+ */
+
+#include <iterator>
+
+#include <mln/core/point2d.hh>
+#include <mln/core/p_set.hh>
+
+
+
+int main()
+{
+ using namespace mln;
+
+ p_set<point2d> ps;
+ ps
+ .insert(make::point2d(6, 9))
+ .insert(make::point2d(4, 2))
+ .insert(make::point2d(4, 2))
+ .insert(make::point2d(5, 1));
+ mln_assertion(ps.npoints() == 3);
+
+ std::cout << ps.bbox() << std::endl;
+
+ std::copy(ps.vect().begin(), ps.vect().end(),
+ std::ostream_iterator<point2d>(std::cout, " "));
+ std::cout << std::endl;
+}
Index: trunk/milena/sandbox/pellegrin/set/test/p_priority_queue_fast_with_array.cc
===================================================================
--- trunk/milena/sandbox/pellegrin/set/test/p_priority_queue_fast_with_array.cc (revision 0)
+++ trunk/milena/sandbox/pellegrin/set/test/p_priority_queue_fast_with_array.cc (revision 1794)
@@ -0,0 +1,105 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+/*! \file tests/core/p_priority_queue_fast_with_array.cc
+ *
+ * \brief Tests on mln::p_priority_queue_fast_with_array.
+ */
+
+#include <mln/core/point2d.hh>
+#include <mln/core/p_priority_queue_fast_with_array.hh>
+
+int main ()
+{
+ using namespace mln;
+
+ p_priority_queue_fast_with_array<point2d, unsigned, 20> q;
+ point2d p1 (6, 9);
+ point2d p2 (5, 1);
+ point2d p3 (4, 2);
+
+ mln_assertion (q.is_empty ());
+ mln_assertion (q.npoints () == 0);
+
+ q.push_force (p3);
+ mln_assertion (!q.is_empty ());
+ mln_assertion (q.npoints () == 1);
+
+ q.push_force (p1, 3);
+ mln_assertion (!q.is_empty ());
+ mln_assertion (q.npoints () == 2);
+
+ q.push_force (p2, 5);
+ mln_assertion (!q.is_empty ());
+ mln_assertion (q.npoints () == 3);
+
+ std::cout << q.bbox () << std::endl;
+ std::cout << q << std::endl;
+
+ mln_assertion (!q.is_empty ());
+
+ mln_assertion (q.has (p1));
+ mln_assertion (q.has (p2));
+ mln_assertion (q.has (p3));
+
+ mln_assertion (q.npoints () == 3);
+ mln_assertion (q.front () == p2);
+ q.pop ();
+
+ mln_assertion (q.has (p1));
+ mln_assertion (!q.has (p2));
+ mln_assertion (q.has (p3));
+
+ mln_assertion (q.npoints () == 2);
+ mln_assertion (q.front () == p1);
+ q.pop ();
+
+ mln_assertion (!q.has (p1));
+ mln_assertion (!q.has (p2));
+ mln_assertion (q.has (p3));
+
+ mln_assertion (q.npoints () == 1);
+ mln_assertion (q.front () == p3);
+ q.pop ();
+
+ mln_assertion (!q.has (p1));
+ mln_assertion (!q.has (p2));
+ mln_assertion (!q.has (p3));
+ mln_assertion (q.npoints () == 0);
+
+ mln_assertion (q.is_empty ());
+
+ q.push_force (p3);
+ q.push_force (p2, 5);
+ q.push_force (p1, 3);
+
+ mln_assertion (q[2] == p3);
+ mln_assertion (q[1] == p1);
+ mln_assertion (q[0] == p2);
+ q.clear ();
+ mln_assertion (q.is_empty ());
+}
Index: trunk/milena/sandbox/pellegrin/set/trait/point_set.hh
===================================================================
--- trunk/milena/sandbox/pellegrin/set/trait/point_set.hh (revision 1793)
+++ trunk/milena/sandbox/pellegrin/set/trait/point_set.hh (revision 1794)
@@ -49,7 +49,7 @@
template <typename P> struct p_line_graph;
template <typename P, typename T> struct p_priority_queue;
template <typename P, typename T> struct p_priority_queue_fast;
- template <typename P, typename T, typename S> struct p_priority_queue_fast_with_array;
+ template <typename P, typename T, unsigned S> struct p_priority_queue_fast_with_array;
template <typename P> struct p_queue;
template <typename P> struct p_queue_fast;
template <typename P> struct p_run;
Index: trunk/milena/sandbox/pellegrin/set/core/p_priority_queue_fast.hh
===================================================================
--- trunk/milena/sandbox/pellegrin/set/core/p_priority_queue_fast.hh (revision 1793)
+++ trunk/milena/sandbox/pellegrin/set/core/p_priority_queue_fast.hh (revision 1794)
@@ -44,7 +44,7 @@
# include <mln/core/p_array_piter.hh>
# include <mln/accu/bbox.hh>
# include <mln/core/p_queue_fast.hh>
-# include <mln/trait/point_set.hh>
+# include <trait/point_set.hh>
namespace mln
@@ -64,7 +64,7 @@
{
typedef trait::point_set::arity::unique arity;
typedef trait::point_set::has_speed::fast has_speed;
- }
+ };
}
Index: trunk/milena/sandbox/pellegrin/set/core/p_bgraph.hh
===================================================================
--- trunk/milena/sandbox/pellegrin/set/core/p_bgraph.hh (revision 1793)
+++ trunk/milena/sandbox/pellegrin/set/core/p_bgraph.hh (revision 1794)
@@ -39,7 +39,7 @@
# include <mln/util/internal/boost_graph.hh>
# include <mln/core/bgraph_psite.hh>
# include <mln/core/p_bgraph_piter.hh>
-# include <mln/trait/point_set.hh>
+# include <trait/point_set.hh>
namespace mln
@@ -57,7 +57,7 @@
{
typedef trait::point_set::arity::unique arity;
typedef trait::point_set::has_speed::fast has_speed;
- }
+ };
}
Index: trunk/milena/sandbox/pellegrin/set/core/p_run.hh
===================================================================
--- trunk/milena/sandbox/pellegrin/set/core/p_run.hh (revision 1793)
+++ trunk/milena/sandbox/pellegrin/set/core/p_run.hh (revision 1794)
@@ -36,7 +36,7 @@
# include <mln/core/internal/point_set_base.hh>
# include <mln/core/internal/set_of.hh>
# include <mln/accu/bbox.hh>
-# include <mln/trait/point_set.hh>
+# include <trait/point_set.hh>
namespace mln
@@ -55,7 +55,7 @@
{
typedef trait::point_set::arity::unique arity;
typedef trait::point_set::has_speed::fast has_speed;
- }
+ };
}
Index: trunk/milena/sandbox/pellegrin/set/core/p_line_graph.hh
===================================================================
--- trunk/milena/sandbox/pellegrin/set/core/p_line_graph.hh (revision 1793)
+++ trunk/milena/sandbox/pellegrin/set/core/p_line_graph.hh (revision 1794)
@@ -35,7 +35,7 @@
# include <mln/core/line_graph_psite.hh>
# include <mln/core/p_line_graph_piter.hh>
# include <mln/core/point_pair.hh>
-# include <mln/trait/point_set.hh>
+# include <trait/point_set.hh>
/* FIXME: This class shares a lot with p_graph. Factor as much as
@@ -67,7 +67,7 @@
{
typedef trait::point_set::arity::unique arity;
typedef trait::point_set::has_speed::fast has_speed;
- }
+ };
}
Index: trunk/milena/sandbox/pellegrin/set/core/pset_if.hh
===================================================================
--- trunk/milena/sandbox/pellegrin/set/core/pset_if.hh (revision 1793)
+++ trunk/milena/sandbox/pellegrin/set/core/pset_if.hh (revision 1794)
@@ -35,7 +35,7 @@
# include <mln/core/internal/point_set_base.hh>
# include <mln/core/concept/function.hh>
-# include <mln/trait/point_set.hh>
+# include <trait/point_set.hh>
namespace mln
@@ -54,7 +54,7 @@
{
typedef trait::point_set::arity::unique arity;
typedef trait::point_set::has_speed::slow has_speed;
- }
+ };
}
Index: trunk/milena/sandbox/pellegrin/set/core/p_array.hh
===================================================================
--- trunk/milena/sandbox/pellegrin/set/core/p_array.hh (revision 1793)
+++ trunk/milena/sandbox/pellegrin/set/core/p_array.hh (revision 1794)
@@ -37,7 +37,7 @@
# include <mln/core/internal/point_set_base.hh>
# include <mln/accu/bbox.hh>
-# include <mln/trait/point_set.hh>
+# include <trait/point_set.hh>
namespace mln
@@ -56,7 +56,7 @@
{
typedef trait::point_set::arity::multiple arity;
typedef trait::point_set::has_speed::fast has_speed;
- }
+ };
}
Index: trunk/milena/sandbox/pellegrin/set/core/concept/point_set.hh
===================================================================
--- trunk/milena/sandbox/pellegrin/set/core/concept/point_set.hh (revision 1793)
+++ trunk/milena/sandbox/pellegrin/set/core/concept/point_set.hh (revision 1794)
@@ -38,7 +38,7 @@
# include <mln/core/concept/point_site.hh>
# include <mln/core/concept/point_iterator.hh>
-# include <mln/trait/point_set.hh>
+# include <trait/point_set.hh>
namespace mln
@@ -96,7 +96,6 @@
bool operator==(const Point_Set<Sl>& lhs, const Point_Set<Sr>& rhs);
-
/*! \brief Inclusion test between point sets \p lhs and \p rhs.
*
* \param[in] lhs A point set (included?).
@@ -108,7 +107,6 @@
bool operator<=(const Point_Set<Sl>& lhs, const Point_Set<Sr>& rhs);
-
/*! \brief Strict inclusion test between point sets \p lhs and \p
* rhs.
*
@@ -121,7 +119,6 @@
bool operator<(const Point_Set<Sl>& lhs, const Point_Set<Sr>& rhs);
-
/*! \brief Print a point set \p pset into the output stream \p
* ostr.
*
@@ -136,7 +133,6 @@
std::ostream& operator<<(std::ostream& ostr, const Point_Set<S>& pset);
-
# ifndef MLN_INCLUDE_ONLY
// fwd decl
@@ -245,8 +241,6 @@
} // end of namespace mln
-
# include <mln/core/ops.hh>
-
#endif // ! MLN_CORE_CONCEPT_POINT_SET_HH
Index: trunk/milena/sandbox/pellegrin/set/core/p_queue.hh
===================================================================
--- trunk/milena/sandbox/pellegrin/set/core/p_queue.hh (revision 1793)
+++ trunk/milena/sandbox/pellegrin/set/core/p_queue.hh (revision 1794)
@@ -41,7 +41,7 @@
# include <mln/core/internal/point_set_base.hh>
# include <mln/core/p_array_piter.hh>
# include <mln/accu/bbox.hh>
-# include <mln/trait/point_set.hh>
+# include <trait/point_set.hh>
namespace mln
@@ -60,7 +60,7 @@
{
typedef trait::point_set::arity::unique arity;
typedef trait::point_set::has_speed::slow has_speed;
- }
+ };
}
Index: trunk/milena/sandbox/pellegrin/set/core/p_priority_queue.hh
===================================================================
--- trunk/milena/sandbox/pellegrin/set/core/p_priority_queue.hh (revision 1793)
+++ trunk/milena/sandbox/pellegrin/set/core/p_priority_queue.hh (revision 1794)
@@ -44,7 +44,7 @@
# include <mln/core/p_array_piter.hh>
# include <mln/accu/bbox.hh>
# include <mln/core/p_queue.hh>
-# include <mln/trait/point_set.hh>
+# include <trait/point_set.hh>
namespace mln
@@ -58,13 +58,13 @@
namespace trait
{
- template <typename P>
- struct point_set_< p_priority_queue<P> >
- : public default_point_set_< p_priority_queue<P> >
+ template <typename P, typename T>
+ struct point_set_< p_priority_queue<P, T> >
+ : public default_point_set_< p_priority_queue<P, T> >
{
typedef trait::point_set::arity::unique arity;
typedef trait::point_set::has_speed::slow has_speed;
- }
+ };
}
Index: trunk/milena/sandbox/pellegrin/set/core/p_runs.hh
===================================================================
--- trunk/milena/sandbox/pellegrin/set/core/p_runs.hh (revision 1793)
+++ trunk/milena/sandbox/pellegrin/set/core/p_runs.hh (revision 1794)
@@ -42,7 +42,7 @@
# include <mln/core/p_run.hh>
# include <mln/accu/bbox.hh>
# include <mln/util/lazy_set.hh>
-# include <mln/trait/point_set.hh>
+# include <trait/point_set.hh>
namespace mln
@@ -61,7 +61,7 @@
{
typedef trait::point_set::arity::multiple arity;
typedef trait::point_set::has_speed::fast has_speed;
- }
+ };
}
Index: trunk/milena/sandbox/pellegrin/set/core/p_set.hh
===================================================================
--- trunk/milena/sandbox/pellegrin/set/core/p_set.hh (revision 1793)
+++ trunk/milena/sandbox/pellegrin/set/core/p_set.hh (revision 1794)
@@ -37,7 +37,7 @@
# include <mln/core/internal/set_of.hh>
# include <mln/accu/bbox.hh>
# include <mln/core/p_array.hh>
-# include <mln/trait/point_set.hh>
+# include <trait/point_set.hh>
namespace mln
@@ -54,7 +54,7 @@
{
typedef trait::point_set::arity::unique arity;
typedef trait::point_set::has_speed::fast has_speed;
- }
+ };
}
Index: trunk/milena/sandbox/pellegrin/set/core/p_priority_queue_fast_with_array.hh
===================================================================
--- trunk/milena/sandbox/pellegrin/set/core/p_priority_queue_fast_with_array.hh (revision 1793)
+++ trunk/milena/sandbox/pellegrin/set/core/p_priority_queue_fast_with_array.hh (revision 1794)
@@ -44,27 +44,27 @@
# include <mln/core/p_array_piter.hh>
# include <mln/accu/bbox.hh>
# include <mln/core/p_queue_fast.hh>
-# include <mln/trait/point_set.hh>
+# include <trait/point_set.hh>
namespace mln
{
// Fwd decls.
- template <typename P, typename T, typename S> struct p_priority_queue_fast_with_array;
+ template <typename P, typename T, unsigned S> struct p_priority_queue_fast_with_array;
template <typename P> struct p_array_fwd_piter_;
template <typename P> struct p_array_bkd_piter_;
namespace trait
{
- template <typename P, typename T, typename S>
+ template <typename P, typename T, unsigned S>
struct point_set_< p_priority_queue_fast_with_array<P, T, S> >
: public default_point_set_< p_priority_queue_fast_with_array<P, T, S> >
{
typedef trait::point_set::arity::multiple arity;
typedef trait::point_set::has_speed::fast has_speed;
- }
+ };
}
Index: trunk/milena/sandbox/pellegrin/set/core/line2d.hh
===================================================================
--- trunk/milena/sandbox/pellegrin/set/core/line2d.hh (revision 1793)
+++ trunk/milena/sandbox/pellegrin/set/core/line2d.hh (revision 1794)
@@ -39,7 +39,7 @@
# include <mln/core/p_array_piter.hh>
# include <mln/core/box2d.hh>
# include <mln/math/all.hh>
-# include <mln/trait/point_set.hh>
+# include <trait/point_set.hh>
namespace mln
@@ -56,7 +56,7 @@
{
typedef trait::point_set::arity::unique arity;
typedef trait::point_set::has_speed::fast has_speed;
- }
+ };
}
Index: trunk/milena/sandbox/pellegrin/set/core/internal/multi_set.hh
===================================================================
--- trunk/milena/sandbox/pellegrin/set/core/internal/multi_set.hh (revision 0)
+++ trunk/milena/sandbox/pellegrin/set/core/internal/multi_set.hh (revision 1794)
@@ -0,0 +1,176 @@
+// 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 MULTI_SET_HH
+# define MULTI_SET_HH
+
+/*! \file sandbox/pellegrin/set/multi_set.hh
+ *
+ * \brief Definition of a point multi-set class.
+ */
+
+# include <mln/core/internal/point_set_base.hh>
+# include <mln/core/internal/set_of.hh>
+
+
+namespace mln
+{
+
+ /*! \brief Point set class.
+ *
+ * This is a mathematical multi-set of points. The
+ * parameter \p P shall be a Point type.
+ *
+ * \todo All.
+ */
+ template <typename P>
+ class multi_set : public internal::point_set_base_< P, p_set<P> >,
+ private internal::set_of_<P>
+ {
+ typedef internal::set_of_<P> super_;
+
+ public:
+ /// Forward Point_Iterator associated type.
+ typedef multi_set_fwd_piter_<P> fwd_piter;
+ /// Backward Point_Iterator associated type.
+ typedef multi_set_bkd_piter_<P> bkd_piter;
+
+ /// Constructor.
+ multi_set();
+
+ /// Test is \p p belongs to this point set.
+ bool has(const P& p) const;
+
+ /// Return the corresponding std::vector of points.
+ using super_::vect;
+
+ /// Give the number of points.
+ std::size_t npoints() const;
+
+ /// Insert a point \p p.
+ multi_set<P>& insert(const P& p);
+
+ // FIXME : doesn't compile
+ // /// Remove a point \p p.
+ // p_set<P>& remove(P& p);
+
+ /// Return the \p i-th point.
+ const P& operator[](unsigned i) const;
+
+ /// Clear this set.
+ void clear();
+
+ /// Give the exact bounding box.
+ const box_<mln_point(P)>& bbox() const;
+
+ protected:
+
+ accu::bbox<P> bb_;
+ // FIXME: Add invariant bb_.is_valid() <=> npoints() != 0
+ };
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename P>
+ inline
+ multi_set<P>::multi_set()
+ {
+ }
+
+ template <typename P>
+ inline
+ bool
+ multi_set<P>::has(const P& p) const
+ {
+ return this->super_::has(p);
+ }
+
+ template <typename P>
+ inline
+ std::size_t
+ multi_set<P>::npoints() const
+ {
+ return this->super_::nelements();
+ }
+
+ template <typename P>
+ inline
+ multi_set<P>&
+ multi_set<P>::insert(const P& p)
+ {
+ this->super_::insert(p);
+ bb_.take(p);
+ return *this;
+ }
+
+
+ // FIXME : finish it.
+ // template <typename P>
+ // p_set<P>&
+ // p_set<P>::remove(P& p)
+ // {
+ // this->super_::remove(p);
+ // // FIXME: need to rebuild bb_ ?
+ // //bb_.untake(p);
+ // return *this;
+ // }
+
+ template <typename P>
+ inline
+ const P&
+ multi_set<P>::operator[](unsigned i) const
+ {
+ mln_precondition(i < npoints());
+ return this->super_::element(i);
+ }
+
+ template <typename P>
+ inline
+ void
+ multi_set<P>::clear()
+ {
+ this->super_::clear();
+ bb_.init();
+ }
+
+ template <typename P>
+ inline
+ const box_<mln_point(P)>&
+ multi_set<P>::bbox() const
+ {
+ mln_precondition(npoints() != 0);
+ return bb_.to_result();
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+} // end of namespace mln
+
+
+#endif // ! MULTI_SET_HH
Index: trunk/milena/sandbox/pellegrin/set/core/internal/uni_set.hh
===================================================================
--- trunk/milena/sandbox/pellegrin/set/core/internal/uni_set.hh (revision 0)
+++ trunk/milena/sandbox/pellegrin/set/core/internal/uni_set.hh (revision 1794)
@@ -0,0 +1,176 @@
+// 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 UNI_SET_HH
+# define UNI_SET_HH
+
+/*! \file sandbox/pellegrin/set/uni_set.hh
+ *
+ * \brief Definition of a point uni-set class.
+ */
+
+# include <mln/core/internal/point_set_base.hh>
+# include <mln/core/internal/set_of.hh>
+
+
+namespace mln
+{
+
+ /*! \brief Point set class.
+ *
+ * This is a mathematical uni-set of points (not a multi-set). The
+ * parameter \p P shall be a Point type.
+ *
+ * \todo All.
+ */
+ template <typename P>
+ class uni_set : public internal::point_set_base_< P, p_set<P> >,
+ private internal::set_of_<P>
+ {
+ typedef internal::set_of_<P> super_;
+
+ public:
+ /// Forward Point_Iterator associated type.
+ typedef uni_set_fwd_piter_<P> fwd_piter;
+ /// Backward Point_Iterator associated type.
+ typedef uni_set_bkd_piter_<P> bkd_piter;
+
+ /// Constructor.
+ uni_set();
+
+ /// Test is \p p belongs to this point set.
+ bool has(const P& p) const;
+
+ /// Return the corresponding std::vector of points.
+ using super_::vect;
+
+ /// Give the number of points.
+ std::size_t npoints() const;
+
+ /// Insert a point \p p.
+ uni_set<P>& insert(const P& p);
+
+ // FIXME : doesn't compile
+ // /// Remove a point \p p.
+ // p_set<P>& remove(P& p);
+
+ /// Return the \p i-th point.
+ const P& operator[](unsigned i) const;
+
+ /// Clear this set.
+ void clear();
+
+ /// Give the exact bounding box.
+ const box_<mln_point(P)>& bbox() const;
+
+ protected:
+
+ accu::bbox<P> bb_;
+ // FIXME: Add invariant bb_.is_valid() <=> npoints() != 0
+ };
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename P>
+ inline
+ uni_set<P>::uni_set()
+ {
+ }
+
+ template <typename P>
+ inline
+ bool
+ uni_set<P>::has(const P& p) const
+ {
+ return this->super_::has(p);
+ }
+
+ template <typename P>
+ inline
+ std::size_t
+ uni_set<P>::npoints() const
+ {
+ return this->super_::nelements();
+ }
+
+ template <typename P>
+ inline
+ uni_set<P>&
+ uni_set<P>::insert(const P& p)
+ {
+ this->super_::insert(p);
+ bb_.take(p);
+ return *this;
+ }
+
+
+ // FIXME : finish it.
+ // template <typename P>
+ // p_set<P>&
+ // p_set<P>::remove(P& p)
+ // {
+ // this->super_::remove(p);
+ // // FIXME: need to rebuild bb_ ?
+ // //bb_.untake(p);
+ // return *this;
+ // }
+
+ template <typename P>
+ inline
+ const P&
+ uni_set<P>::operator[](unsigned i) const
+ {
+ mln_precondition(i < npoints());
+ return this->super_::element(i);
+ }
+
+ template <typename P>
+ inline
+ void
+ uni_set<P>::clear()
+ {
+ this->super_::clear();
+ bb_.init();
+ }
+
+ template <typename P>
+ inline
+ const box_<mln_point(P)>&
+ uni_set<P>::bbox() const
+ {
+ mln_precondition(npoints() != 0);
+ return bb_.to_result();
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+} // end of namespace mln
+
+
+#endif // ! UNI_SET_HH
Index: trunk/milena/sandbox/pellegrin/set/core/p_graph.hh
===================================================================
--- trunk/milena/sandbox/pellegrin/set/core/p_graph.hh (revision 1793)
+++ trunk/milena/sandbox/pellegrin/set/core/p_graph.hh (revision 1794)
@@ -34,7 +34,7 @@
# include <mln/util/graph.hh>
# include <mln/core/graph_psite.hh>
# include <mln/core/p_graph_piter.hh>
-# include <mln/trait/point_set.hh>
+# include <trait/point_set.hh>
/// \file mln/core/p_graph.hh
@@ -55,7 +55,7 @@
{
typedef trait::point_set::arity::unique arity;
typedef trait::point_set::has_speed::fast has_speed;
- }
+ };
}
Index: trunk/milena/sandbox/pellegrin/set/core/p_queue_fast.hh
===================================================================
--- trunk/milena/sandbox/pellegrin/set/core/p_queue_fast.hh (revision 1793)
+++ trunk/milena/sandbox/pellegrin/set/core/p_queue_fast.hh (revision 1794)
@@ -42,7 +42,7 @@
# include <mln/core/internal/point_set_base.hh>
# include <mln/core/p_array_piter.hh>
# include <mln/accu/bbox.hh>
-# include <mln/trait/point_set.hh>
+# include <trait/point_set.hh>
namespace mln
@@ -61,7 +61,7 @@
{
typedef trait::point_set::arity::multiple arity;
typedef trait::point_set::has_speed::fast has_speed;
- }
+ };
}
--
Michel PELLEGRIN
ÉPITA - CSI 2010
1
0