URL:
https://svn.lrde.epita.fr/svn/oln/trunk/milena
ChangeLog:
2007-10-22 Matthieu Garrigues <garrigues(a)lrde.epita.fr>
Try to add remove to set_of, Update fllt.
* mln/core/internal/set_of.hh: (set_of::remove) New.
* mln/core/set_p.hh: (set_p::remove) New.
* sandbox/garrigues/fllt.hh: Update.
---
mln/core/internal/set_of.hh | 23 +++++++++++++++++++++++
mln/core/set_p.hh | 16 ++++++++++++++++
sandbox/garrigues/fllt.hh | 23 ++++++++++++++++-------
3 files changed, 55 insertions(+), 7 deletions(-)
Index: trunk/milena/mln/core/internal/set_of.hh
===================================================================
--- trunk/milena/mln/core/internal/set_of.hh (revision 1371)
+++ trunk/milena/mln/core/internal/set_of.hh (revision 1372)
@@ -36,6 +36,7 @@
# include <vector>
# include <set>
# include <iterator>
+# include <algorithm>
# include <mln/core/internal/force_exact.hh>
@@ -79,6 +80,17 @@
set_of_<E>& insert(const E& elt);
+ /*! \brief Remove an element \p elt into the set.
+ *
+ * \param[in] elt The element to be inserted.
+ *
+ * If \p elt is already in the set, this method is a no-op.
+ *
+ * \return The set itself after suppression.
+ */
+ set_of_<E>& remove(const E& elt);
+
+
/*! \brief Return the i-th element of the set.
*
* \param[in] i Index of the element to retrieve.
@@ -193,6 +205,17 @@
}
template <typename E>
+ set_of_<E>&
+ set_of_<E>::remove(const E& elt)
+ {
+ // FIXME : doesn't compile
+ std::remove(s_.begin(), s_.end(), elt);
+ if (needs_update_ == false)
+ needs_update_ = true;
+ return internal::force_exact< set_of_<E> >(*this);
+ }
+
+ template <typename E>
const E&
set_of_<E>::element(unsigned i) const
{
Index: trunk/milena/mln/core/set_p.hh
===================================================================
--- trunk/milena/mln/core/set_p.hh (revision 1371)
+++ trunk/milena/mln/core/set_p.hh (revision 1372)
@@ -78,6 +78,10 @@
/// Insert a point \p p.
set_p<P>& insert(const P& p);
+ // FIXME : doesn't compile
+ // /// Remove a point \p p.
+ // set_p<P>& remove(P& p);
+
/// Return the \p i-th point.
const P& operator[](unsigned i) const;
@@ -124,6 +128,18 @@
return *this;
}
+
+ // FIXME : finish it.
+ // template <typename P>
+ // set_p<P>&
+ // set_p<P>::remove(P& p)
+ // {
+ // this->super_::remove(p);
+ // // FIXME: need to rebuild bb_ ?
+ // //bb_.untake(p);
+ // return *this;
+ // }
+
template <typename P>
const P&
set_p<P>::operator[](unsigned i) const
Index: trunk/milena/sandbox/garrigues/fllt.hh
===================================================================
--- trunk/milena/sandbox/garrigues/fllt.hh (revision 1371)
+++ trunk/milena/sandbox/garrigues/fllt.hh (revision 1372)
@@ -26,8 +26,8 @@
// Public License.
-#ifndef MLN_LEVEL_MEDIAN_HH
-# define MLN_LEVEL_MEDIAN_HH
+#ifndef MLN_FIXME_FLLT_HH
+# define MLN_FIXME_FLLT_HH
/*! \file fllt.hh
*
@@ -202,7 +202,7 @@
// follow each border to find which is the exterior border
// and which are the holes. Keep one pixel of each holes.
-// Remove from N border of holes.
+// Remove from N border of holes???.
// Recompute gn <- min u(x) x belongs to A
}
@@ -223,6 +223,7 @@
set_p<P>& N,
V& g)
{
+ std::cout << "entering step 4_2" << std::endl;
// A <- {x belongs to N / u(x) == g}
// N <- N\{x belongs to N / u(x) == g}
@@ -240,14 +241,19 @@
N.insert(p);
}
}
+
+ std::cout << "exiting step 4_2" << std::endl;
}
/// IF g > gn.
template <typename V, typename P>
void step4_3 (image2d<V>& u,
+ image2d<bool>& tagged,
set_p<P>& R,
V& g)
{
+ std::cout << "entering step 4_3" << std::endl;
+
// set the gray-level of the pixels of R to g.
mln_piter(set_p<P>) p(R);
for_all(p)
@@ -255,6 +261,9 @@
mln_assertion (tagged(p));
u (p) = g;
}
+
+ std::cout << "exiting step 4_3" << std::endl;
+
}
@@ -288,7 +297,8 @@
/// Algorithm.
{
- mln_piter(I_IF) p((min_locals | (pw::value(min_locals) >
pw::cst(0))).domain());
+ I_IF min_locals_list(min_locals | (pw::value(min_locals) > pw::cst(0)));
+ mln_piter(I_IF) p(min_locals_list.domain());
for_all(p)
{
if (tagged(p))
@@ -321,8 +331,7 @@
if (g > gn)
{
- /// FIXME ima -> u
- // step4_3(u, R, g);
+ step4_3(u, tagged, R, g);
// GO TO 1)
break;
}
@@ -335,4 +344,4 @@
-#endif // ! MLN_LEVEL_MEDIAN_HH
+#endif // ! MLN_FIXME_FLLT_HH